在 java 中将 String 替换为另一个字符串
什么函数可以用另一个字符串替换一个字符串?
示例 #1:什么将替换为 ?"HelloBrother"
"Brother"
示例#2:什么将替换为?"JAVAISBEST"
"BEST"
什么函数可以用另一个字符串替换一个字符串?
示例 #1:什么将替换为 ?"HelloBrother"
"Brother"
示例#2:什么将替换为?"JAVAISBEST"
"BEST"
String a = "HelloBrother How are you!";
String r = a.replace("HelloBrother","Brother");
System.out.println(r);
这将打印出“兄弟你好吗!