1.创建新的字符串 public class T004 { public static void main(String[] args){ System.out.println(replaceBlank("we are happy")); } public static String replaceBlank(String s){ String r = "%20"; String result = ""; for(int i=0;i<s.l
面试题 5. 替换空格 题目:请实现一个函数,将一个字符串中的空格替换成"%20".例如,当字符串为We Are Happy. 则经过替换之后的字符串为We%20Are%20Happy. Java 实现 public class Solution { public String replaceSpace(StringBuffer str) { if(str==null||str.length()==0) return str==null?null:str.toString(); int