【发布时间】:2015-01-03 14:40:31
【问题描述】:
import java.util.regex.*;
public class Regex2 {
public static void main(String[] args) {
Pattern p = Pattern.compile("\\d*");
Matcher m = p.matcher("ab34ef");
boolean b = false;
while ( m.find()) {
System.out.print(m.start() + m.group());
}
}
}
为什么这段代码会产生输出:01234456
【问题讨论】:
-
如果您使用
println,您会更清楚地了解发生了什么。