Java Utililty Methods String Capitalize First

List of utility methods to do String Capitalize First

Description

The list of methods to do String Capitalize First are organized into topic(s).

Method

StringcapitalizeFirstCharacter(String str)
Returns the given String in lower case with the first character capitalized.
if (str == null)
    throw new IllegalArgumentException("Parameter 'str' cannot be null!");
if (str.length() <= 0)
    return "";
str = str.toLowerCase();
StringBuilder sb = new StringBuilder();
sb.append(Character.toUpperCase(str.charAt(0)));
sb.append(str.substring(1));
...
StringcapitalizeFirstCharacter(String str)
Utility method to capitalize first character in the String
char[] chars = str.toCharArray();
char firstChar = chars[0];
chars[0] = Character.toUpperCase(firstChar);
return new String(chars);
StringCapitalizeFirstCharacter(String Str)
Capitalize First Character
if (isNullOrEmpty(Str) == true)
    return null;
if (Str.length() == 1)
    return "" + Character.toUpperCase(Str.charAt(0));
return Character.toUpperCase(Str.charAt(0)) + Str.substring(1);
StringcapitalizeFirstCharacter(String value)
Method capitalizeFirstCharacter
if (isNullOrEmpty(value)) {
    return value;
char[] chars = value.toCharArray();
chars[0] = Character.toUpperCase(chars[0]);
return new String(chars);
StringcapitalizeFirstCharacters(String whole)
capitalize First Characters
final StringBuilder result = new StringBuilder(whole.length());
String[] words = whole.split("\\s");
for (int i = 0, l = words.length; i < l; ++i) {
    if (i > 0)
        result.append(" ");
    result.append(Character.toUpperCase(words[i].charAt(0))).append(words[i].substring(1));
return result.toString();
...
StringcapitalizeFirstCharacterString(String item)
capitalize First Character String
String attributeField = item;
String firstChar = attributeField.substring(0, 1);
firstChar = firstChar.toUpperCase();
return firstChar + attributeField.substring(1);
StringcapitalizeFirstCharOfString(final String input)
Capitalizes first char of an input string.
if (input == null || input.length() == 0) {
    return "";
} else if (input.length() == 1) {
    return input.toUpperCase();
} else {
    return input.substring(0, 1).toUpperCase() + input.substring(1);
StringcapitalizeFirstLeter(String sentence)
Capitalize first letter.
return sentence.substring(0, 1).toUpperCase() + sentence.substring(1);
CharSequencecapitalizeFirstLetter(final CharSequence chars)
Capitalize the first letter of given CharSequence .
final char first = chars.charAt(0);
if (Character.isUpperCase(first)) {
    return chars;
} else {
    CharSequence following = chars.subSequence(1, chars.length());
    return String.valueOf(Character.toUpperCase(first)) + following;
StringcapitalizeFirstLetter(final String aString)
Capitalize the first letter of every word in a string
boolean toUpper = true;
final char[] a = aString.toLowerCase().toCharArray();
for (int i = 0; i < a.length; ++i) {
    if (Character.isWhitespace(a[i])) {
        toUpper = true;
    } else {
        if (toUpper && Character.isLowerCase(a[i])) {
            a[i] = Character.toUpperCase(a[i]);
...