String.split() should return 0 items if input is empty

Ulf Zibis Ulf.Zibis at gmx.de
Sun Jun 13 13:51:39 UTC 2010


On the other hand:
     " ".token.split(" "); // Bug: should return { "" } for token " "
should return:
     { "" } (=new String[1])
but actually returns {  } (=new String[0]) .

-Ulf


Am 13.06.2010 14:39, schrieb Ulf Zibis:
> Correction: 0 items (=new String[0])
> Actually it returns new String[1] with one zero-length String.
>
> -Ulf
>
>
> Am 13.06.2010 14:32, schrieb Ulf Zibis:
>> Shouldn't String.split("x") return 0 items (=null) if input is empty 
>> (=.length()==0),
>> as there is neither a matching pattern "x", nor some trailing chars 
>> and trailing empty strings should be discarded?
>>
>> Thanks,
>>
>> -Ulf
>>
>>
>>
>
>




More information about the core-libs-dev mailing list