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.