@Test void testTitleCase() { String s = "halo dunia!"; String result = Utilities.toTitleCase(s); assertEquals("Halo Dunia!", result); }
public static String toTitleCase(String s) { String result = ""; boolean afterWhitespace = true; for (char c : s.toCharArray()) { if(Character.isWhitespace(c)) { afterWhitespace = true; result += c; continue; } if(afterWhitespace) { result += Character.toUpperCase(c); afterWhitespace = false; } else { result += Character.toLowerCase(c); } } return result; }
Utilities { public static String toTitleCase(String s) { String result = ""; boolean afterWhitespace = true; for (char c : s.toCharArray()) { if(Character.isWhitespace(c)) { afterWhitespace = true; result += c; continue; } if(afterWhitespace) { result += Character.toUpperCase(c); afterWhitespace = false; } else { result += Character.toLowerCase(c); } } return result; } }
Utilities { public static String toTitleCase(String s) { String result = ""; boolean afterWhitespace = true; for (char c : s.toCharArray()) { if(Character.isWhitespace(c)) { afterWhitespace = true; result += c; continue; } if(afterWhitespace) { result += Character.toUpperCase(c); afterWhitespace = false; } else { result += Character.toLowerCase(c); } } return result; }  }
Utilities { public static String toTitleCase(String s) { String result = ""; boolean afterWhitespace = true; for (char c : s.toCharArray()) { if(Character.isWhitespace(c)) { afterWhitespace = true; result += c; continue; } if(afterWhitespace) { result += Character.toUpperCase(c); afterWhitespace = false; } else { result += Character.toLowerCase(c); } } return result; }  static boolean validateEmail(String email); static String toTitleCase(String s); }
Utilities { public static String toTitleCase(String s) { String result = ""; boolean afterWhitespace = true; for (char c : s.toCharArray()) { if(Character.isWhitespace(c)) { afterWhitespace = true; result += c; continue; } if(afterWhitespace) { result += Character.toUpperCase(c); afterWhitespace = false; } else { result += Character.toLowerCase(c); } } return result; }  static boolean validateEmail(String email); static String toTitleCase(String s);  }