Bug in String's split method???




I was trying to write a utility method that work almost the same as the
split method on String, that would work with java versions 1.3 or less,

using Jakarta's ORO library. I though I implemented it according to the
javadoc for the split method on String. But the expression
"".split(",", 0),
returns an array with 1 element, I was expecting an array with no
elements.
The expression ",".split(",", 0) returns an array with no elements.
Is this a bug or am I reading the docs wrong?

Code:
String[] result = null;
result = "".split(",", 0);
System.out.println(result.length);
result = ",".split(",", 0);
System.out.println(result.length);
System.out.println(System.getProperty("java.version"));

Output:
1
0
1.4.2_06

I thing the output should be:
0
0
1.4.2_06

.



Relevant Pages

  • Re: problem with split method
    ... each string and I used split method to sort the array. ... If you want to recreate the string from the sorted array, use the array's join method and pass the character you want as parameter: ...
    (microsoft.public.scripting.jscript)
  • Re: dataset from tab separated
    ... What you need to do is to create empty DataTable first that will have ... Then you read the string and use Split method of String. ... It allows to split delimited data into array. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Find a String in VB.NET
    ... i gave a split method example too...look in this thread. ... op is trying to acheive...one being a delimited string search returning ... | "steve" schreef in bericht ... |> dim regExp as new regEx ...
    (microsoft.public.dotnet.languages.vb)
  • Re: problem with split method
    ... string and I used split method to sort the array. ...
    (microsoft.public.scripting.jscript)
  • Re: read and show CSV-files
    ... public static void main ... // Split method from Substance ... static private String[] split ...
    (comp.lang.java.programmer)