Q: Java String split result 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.

A: Documentation says 

This method works as if by invoking the two-argument split method with
  the given expression and a limit argument of zero. Trailing empty
  strings are therefore not included in the resulting array.

here

A: split(";") will get strings from before, between, and after each single semicolon. So your split array would theoretically be {"name:john","","sex:m","",""} at some point in the operation. However, split() removes trailing empty strings, so you actually get {"name:john","","sex:m"}.
As to why you don't have a terminal semicolons being printed, is because you split over each individual semicolon without a limit. The limit is length of the resulting array.
You can often fix internal empty strings by using the proper regex for multiple characters. You may want to check split(";++"). If you want the terminal semicolons you need to set a limit split(";++",2).

A: It looks like Arrays.toString is representing your split array with space characters, instead of what it would actually be in the array of Strings returned by String.split, which is the empty string "". The final two semicolons on the end are not in the output because String.split only inserts the empty strings into its array where the delimiter you specify occurs within the string, not after it ends.

A: The '' is from the two semicolons that you put in between name:john and sex:m. The fact that they are not at the end is because java ignores empty strings at the end of a list.
