replace两种用法:replace(int start,int end, String str)
replace(char oldchar, char newchar)
public class Solution {
public String replaceSpace(StringBuffer str) {
if (str==null){
return null;
}
else{
//StringBuffer Newstr=new StringBuffer();
for(int i=0;i<str.length();i++){
if(str.charAt(i)==‘ ‘)
str.replace(i,i+1,"%20");
}
return str.toString();
}
}
}