- 考点:字符串的遍历
class Solution {
public String replaceSpace(String s) {
StringBuilder tmp = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == ' ') {
tmp.append("%20");
} else {
tmp.append(s.charAt(i));
}
}
return tmp + "";
}
}