String s="a"; System.out.println(s.replaceAll(".*","1")); 为什么上面的代码输出是“ 11”而不是“ 1”? 最佳答案 由于*匹配一个字符零次或多次。使用+代替,您应该看到区别。