62,614
社区成员
发帖
与我相关
我的任务
分享
public class ChangeString {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println(ChangeString.method1());
}
public static String method1(){
return "I am a Chinese people".replace("Chinese", "Beijing");
}
}
public class Test {
public static void main(String args[]) {
String s = "I am a Chinese people";
s = s.replaceAll("Chinese","Beijing");
System.out.println(s);
}
}
return "I am a Chinese people.".replace("Chinese", "Beijing");
String str = "I am a Chinese people." ;
String newStr="";
String strArr[] = str.spit(" ");
for(int i=0;i<strArr.length;i++){
if(str.equals("Chinese")){
strArr[i]="Beijing";
}
}
for(int i=0;i<strArr.length;i++){
newStr+=strArr[i]+" ";
}