【发布时间】:2011-12-30 17:16:44
【问题描述】:
这是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“当分隔符出现在字符串末尾时,split() 中的错误”
-
这就是 Google Guava 创建 com.google.common.base.Splitter 的原因