replace() 起到了一个字符串替换的作用(修改对象中的元素) 实现代码 String a = "hello wrold"; String b = "a"; a = a.replace("hello",b); System.out.println(a); 输出结果: a wrold
hello被替换成了a
replace() 起到了一个字符串替换的作用(修改对象中的元素) 实现代码 String a = "hello wrold"; String b = "a"; a = a.replace("hello",b); System.out.println(a); 输出结果: a wrold
hello被替换成了a