替换空格_JAVA_较难
替换空格
http://www.nowcoder.com/questionTerminal/4060ac7e3e404ad1a894ef3e17650423
- 遍历替换
public class Solution { public String replaceSpace(StringBuffer str) { StringBuffer res = new StringBuffer(); for(char c : str.toString().toCharArray()) { if(c == ' ') { res.append("%20"); } else { res.append(c); } } return res.toString(); } }