0

我正在编写一些代码的开始阶段,我将在接下来的几个月中对其进行扩展。我现在正在处理的部分只需要一个字符串。我有这个,但我想在某个地方拆分字符串:“(li)”。到目前为止,我有:

String[] s = n.split("(li)")

但这不是编译。错误说:

Error: cannot find symbol
symbol:   method split(java.lang.String)
location: variable s of type java.lang.String[]
4

1 回答 1

0

这应该工作

public static void main(String args[]) {
        String n = "mylitx";
        String[] s = n.split("(li)");
        for (String tag : s)
            System.out.println(tag);
    }

将产生输出为

my
tx
于 2013-09-27T02:41:52.727 回答