Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写一些代码的开始阶段,我将在接下来的几个月中对其进行扩展。我现在正在处理的部分只需要一个字符串。我有这个,但我想在某个地方拆分字符串:“(li)”。到目前为止,我有:
String[] s = n.split("(li)")
但这不是编译。错误说:
Error: cannot find symbol symbol: method split(java.lang.String) location: variable s of type java.lang.String[]
这应该工作
public static void main(String args[]) { String n = "mylitx"; String[] s = n.split("(li)"); for (String tag : s) System.out.println(tag); }
将产生输出为
my tx