英语翻译str怎么打出来?

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/25 06:21:02

英语翻译str怎么打出来?
英语翻译
str怎么打出来?

英语翻译str怎么打出来?
在使用String.split方法分隔字符串时,分隔符如果用到一些特殊字符,可能会得不到我们预期的结果. 我们看jdk doc中说明 public String[] split(String regex) Splits this string around matches of the given regular expression. 参数regex是一个 regular-expression的匹配模式而不是一个简单的String,他对一些特殊的字符可能会出现你预想不到的结果,比如测试下面的代码: 用竖线 | 分隔字符串,你将得不到预期的结果 String[] aa = "aaa|bbb|ccc".split("|"); //String[] aa = "aaa|bbb|ccc".split("\\|"); 这样才能得到正确的结果 for (int i = 0 ; i