public class Groups {
static public final String POEM = "I am singing o\n" + "I am dawning o\n"
+ "I am thinking o\n"; public static void main(String[] args) { Matcher m = Pattern.compile("(?m)(\\S+)\\s+((\\S+)\\s+(\\S+))$")
.matcher(POEM);
while (m.find()) {
for (int j = 0; j <= m.groupCount(); j++) {
System.out.print("[" + m.group(j) + "]");
}
System.out.println();
}
}
}
为什么代码运行没有错,在for循环里面设断点调试的时候却报错,或者在while处设断点就进不去while循环里面,求高手解答!!!!

解决方案 »

  1.   

    运行结果如下:
    [am singing o][am][singing o][singing][o]
    [am dawning o][am][dawning o][dawning][o]
    [am thinking o][am][thinking o][thinking][o]
    按你说的设了断点正常运行啊。。
      

  2.   

    我调试的时候按2下f6,就进入到了Matcher.class然后就进入这个函数
     public String group(int group) {
            if (first < 0)
                throw new IllegalStateException("No match found");
                 ..................
      

  3.   

    [am singing o][am][singing o][singing][o]
    [am dawning o][am][dawning o][dawning][o]
    [am thinking o][am][thinking o][thinking][o]运行正常,调试了也正常