标签:
1 public class Solution { 2 public String replaceSpace(StringBuffer str){ 3 String strTemp = ""; 4 for(int i = 0; i < str.length(); i++){ 5 if(str.charAt(i) == ‘ ‘){ 6 strTemp += "%20"; 7 continue; 8 } 9 strTemp += str.charAt(i); 10 } 11 12 return strTemp; 13 } 14 15 public static void main(String[] args) { 16 Solution solutionBlank = new Solution(); 17 StringBuffer str = new StringBuffer("We Are Happy"); 18 System.out.println(solutionBlank.replaceSpace(str)); 19 } 20 }
标签:
原文地址:http://www.cnblogs.com/wangchaoyuan/p/5958948.html