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循环里面,求高手解答!!!!
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循环里面,求高手解答!!!!
[am singing o][am][singing o][singing][o]
[am dawning o][am][dawning o][dawning][o]
[am thinking o][am][thinking o][thinking][o]
按你说的设了断点正常运行啊。。
public String group(int group) {
if (first < 0)
throw new IllegalStateException("No match found");
..................
}
[am dawning o][am][dawning o][dawning][o]
[am thinking o][am][thinking o][thinking][o]运行正常,调试了也正常