例:
String s = ":a:b:c:";
s.split(":");
// Output: [, a, b, c]
Java Doc から:
The array returned by this method contains each substring of this string that is terminated by another substring that matches the given expression or is terminated by the end of the string.
最後の空の文字列がないのに、最初の空の文字列が考慮されるのはなぜですか? 最初の空の文字列は ":" で終わり、最後の空の文字列は文字列の終わりで終わります。したがって、両方をリストする必要があります。