Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8176088

String.split() method wrong result

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.8.0_121"
      Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.3.9600]

      A DESCRIPTION OF THE PROBLEM :
      Method "::".split(":") returns an empty array.

      The method String.split(int regex) description says that the String object "::" should be split into 3 element array with empty Strings, like this:

      ["", "", ""]

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      "::".split(":").length;



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class HelloWorld
      {
           public static void main(String []args)
           {
              System.out.println("::".split(":").length);
           }
      }
      ---------- END SOURCE ----------

      SUPPORT :
      YES

            aroy Abhijit Roy (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: