字符串的替换(空格替换为 . )
public class Solution {
public String replaceSpace(StringBuffer str) {
String oldstr = str.toString();
return oldstr.replace(" ",".");
}
}
测试方法
public static void main(String[] args) {
StringBuffer oldstr = "www hello com";
String newstr = replaceSpace(oldstr);
System.out,println("替换后的结果是"+newstr);
}