I want to split a string to single characters. So I do:
"abcd".split("");
But this yields:
["", "a", "b", "c", "d"]
The first empty string is not something I'm used to when doing the same in other languages (e.g. Ruby). What is the logic behind it?
substring(i, i+1)orcharAt(i)ortoCharArray()to access characters.[String#split(String)]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."