这是this question的后续行为。空字符串和单分隔符字符串上的字符串拆分行为
问题在下面的第二行。
"".split("x"); //returns {""} // ok
"x".split("x"); //returns {} but shouldn't it return {""} because it's the string before "x" ?
"xa".split("x"); //returns {"", "a"} // see?, here "" is the first string returned
"ax".split("x"); //returns {"a"}
参见[SI-5096(https://issues.scala-lang.org/browse/SI-5069) “的Bug分裂()时,分隔符出现在字符串的结束” – 4e6
这就是为什么谷歌Guava创建了com.google.common.base.Splitter – Schildmeijer