@Test public void testCapWordsTwoWordsMultipleWhitespaces() throws Exception { assertEquals("Captain Shitman", StringUtils.capWords("captain shitman")); }
@NonNull public static String capWords(@NonNull final String input) { boolean prevWasWhiteSp = true; final char[] chars = input.toCharArray(); for (int i = 0; i < chars.length; i++) { if (Character.isLetter(chars[i])) { if (prevWasWhiteSp) { chars[i] = Character.toUpperCase(chars[i]); } prevWasWhiteSp = false; } else { prevWasWhiteSp = Character.isWhitespace(chars[i]); } } return new String(chars); }
StringUtils { @NonNull public static String capWords(@NonNull final String input) { boolean prevWasWhiteSp = true; final char[] chars = input.toCharArray(); for (int i = 0; i < chars.length; i++) { if (Character.isLetter(chars[i])) { if (prevWasWhiteSp) { chars[i] = Character.toUpperCase(chars[i]); } prevWasWhiteSp = false; } else { prevWasWhiteSp = Character.isWhitespace(chars[i]); } } return new String(chars); } }
StringUtils { @NonNull public static String capWords(@NonNull final String input) { boolean prevWasWhiteSp = true; final char[] chars = input.toCharArray(); for (int i = 0; i < chars.length; i++) { if (Character.isLetter(chars[i])) { if (prevWasWhiteSp) { chars[i] = Character.toUpperCase(chars[i]); } prevWasWhiteSp = false; } else { prevWasWhiteSp = Character.isWhitespace(chars[i]); } } return new String(chars); } private  StringUtils(); }
StringUtils { @NonNull public static String capWords(@NonNull final String input) { boolean prevWasWhiteSp = true; final char[] chars = input.toCharArray(); for (int i = 0; i < chars.length; i++) { if (Character.isLetter(chars[i])) { if (prevWasWhiteSp) { chars[i] = Character.toUpperCase(chars[i]); } prevWasWhiteSp = false; } else { prevWasWhiteSp = Character.isWhitespace(chars[i]); } } return new String(chars); } private  StringUtils(); @NonNull static String notNullString(@Nullable final String string); @NonNull static String capWords(@NonNull final String input); }
StringUtils { @NonNull public static String capWords(@NonNull final String input) { boolean prevWasWhiteSp = true; final char[] chars = input.toCharArray(); for (int i = 0; i < chars.length; i++) { if (Character.isLetter(chars[i])) { if (prevWasWhiteSp) { chars[i] = Character.toUpperCase(chars[i]); } prevWasWhiteSp = false; } else { prevWasWhiteSp = Character.isWhitespace(chars[i]); } } return new String(chars); } private  StringUtils(); @NonNull static String notNullString(@Nullable final String string); @NonNull static String capWords(@NonNull final String input);  }