topic
https://leetcode-cn.com/problems/ti-huan-kong-ge-lcof/
Ideas
Traverse each letter of the string into an array and then merge the array into a String
Code
public String replaceSpace2(String s) {
if(s==null){
return s;
}
String[] ss = new String[s.length()];
for (int i = 0; i < s.length(); i++) {
if(s.charAt(i)==' '){
ss[i]="%20";
}else {
ss[i] = s.charAt(i)+"";
}
}
return String.join("",ss);
}