题解 | #替换空格#
替换空格
https://www.nowcoder.com/practice/0e26e5551f2b489b9f58bc83aa4b6c68
import java.util.*;
public class Solution {
public String replaceSpace (String s) {
String new_str = "";
int len = s.length();
for(int i = 0; i < len; i++){
if(s.charAt(i)==' '){
new_str = new_str + "%20";
}
else{
new_str = new_str + s.charAt(i);
}
}
return new_str;
}
}
public class Solution {
public String replaceSpace (String s) {
String new_str = "";
int len = s.length();
for(int i = 0; i < len; i++){
if(s.charAt(i)==' '){
new_str = new_str + "%20";
}
else{
new_str = new_str + s.charAt(i);
}
}
return new_str;
}
}