将字符串S使用replaceAll方法后,输出s仍未替换

replace方法并不能改变字符串本身的,只是replace方法能返回一个处理后的字符串而已,例如:
String s="hello";
System.out.println(s.replace("h","H"));
System.out.println(s);
输出结果:
Hello
hello

你可能感兴趣的:(将字符串S使用replaceAll方法后,输出s仍未替换)