1.5 Write a method to replace all spaces in a string with ‘%20’.
string.replace(" ", "%20"); ??
// Manipulating chars. String replaceSpaces(String s) { if (s == null) return null; char[] chars = s.toCharArray(); StringBuilder sb = new StringBuilder(); for (char c : chars) { if (c != ' ') { sb.append(c); } else { sb.append("%20"); } } return sb.toString(); }