java - Behaviour of String.split() when input is empty -


as title explains query

can please explain behavior of following 2 outputs.

"".split(",").length 

gives output

1 

where as

",".split(",").length 

gives output

0 

in first case, original string returned, because separator not found.

from api docs:

if expression not match part of input resulting array has 1 element, namely string.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -