标签:append else pen str logs 字符串 for char build
方法一:
public class Solution { public String replaceSpace(StringBuffer str) { String a=str.toString(); char[] b = a.toCharArray(); StringBuilder sBuilder = new StringBuilder(); for (char c : b) { if(c==‘ ‘) { sBuilder.append("%20"); }else { sBuilder.append(c); } } String e = sBuilder.toString(); return e; } }
java:当字符串为We Are Happy.经过替换之后的字符串为We%20Are%20Happy
标签:append else pen str logs 字符串 for char build
原文地址:http://www.cnblogs.com/zterry/p/6536037.html