List of utility methods to do String Capitalize
String | capitalize(String s) Capitalizes the first letter in the string s return Character.toUpperCase(s.charAt(0)) + s.substring(1);
|
String | capitalize(final String name) capitalize if (isEmpty(name)) { return name; char chars[] = name.toCharArray(); chars[0] = Character.toUpperCase(chars[0]); return new String(chars); |
String | decapitalize(final String name) decapitalize if (isEmpty(name)) { return name; char chars[] = name.toCharArray(); if (chars.length >= 2 && Character.isUpperCase(chars[0]) && Character.isUpperCase(chars[1])) { return name; chars[0] = Character.toLowerCase(chars[0]); return new String(chars); |
String | capitalize(String string) capitalize if (string.length() > 1) return string.substring(0, 1).toUpperCase() + string.substring(1); return ""; |
String | decapitalize(String string) Decapitalize a String if it begins with a capital letter, e.g.: FooBar -> fooBar char c0 = string.charAt(0); if (!Character.isUpperCase(c0)) { return string; if (string.length() > 1 && Character.isUpperCase(string.charAt(1))) { return string; char[] chars = string.toCharArray(); ... |
String | capitalizeFirstLetter(String str) capitalize first letter capitalizeFirstLetter(null) = null; capitalizeFirstLetter("") = ""; capitalizeFirstLetter("2ab") = "2ab" capitalizeFirstLetter("a") = "A" capitalizeFirstLetter("ab") = "Ab" capitalizeFirstLetter("Abc") = "Abc" if (isEmpty(str)) { return str; char c = str.charAt(0); return (!Character.isLetter(c) || Character.isUpperCase(c)) ? str : new StringBuilder(str.length()) .append(Character.toUpperCase(c)) .append(str.substring(1)).toString(); ... |
String | capitalize(String line) capitalize return Character.toUpperCase(line.charAt(0)) + line.substring(1);
|
String | capitalize(String s) Capitalizes first character of the string if (s == null || s.length() == 0) { return ""; char first = s.charAt(0); if (Character.isUpperCase(first)) { return s; } else { return Character.toUpperCase(first) + s.substring(1); ... |