标签:art dex tin sys out 空格替换 函数 替换 off
1 public class Solution { 2 public String replaceSpace(StringBuffer str) { 3 int startIndex; 4 while((startIndex = str.indexOf(" ")) >= 0){ 5 str.replace(startIndex, startIndex + 1, "%20"); 6 } 7 System.out.println(str); 8 return str.toString(); 9 } 10 }
解题思路:用indexOf()寻找“ ”字符串,用replace()将其替换成“%20”;
标签:art dex tin sys out 空格替换 函数 替换 off
原文地址:http://www.cnblogs.com/yangnk/p/6599110.html