英语翻译str怎么打出来?

有热闹就去看 1年前 已收到1个回答 举报

pfneiml 幼苗

共回答了20个问题采纳率:80% 举报

在使用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

1年前

1
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.024 s. - webmaster@yulucn.com