I don't understand why this is getting an output of 3:
String[] split = "name:john;;sex:m;;".split(";");
System.out.println(Arrays.toString(split) + " size " + split.length);
I have read Oracle documentation and I still wihout getting why is 3.
Why the output is:
[name:john, , sex:m] size 3
Where is taking the ' ' (the second on the list), and also why the ";;" at the end is not in the output.
;, so that emptiness between the;;is whats taking it. Split on;;Trailing empty strings are therefore not included in the resulting array.