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

StringcapitalizeFirstLetter(String string)
This method capitalizes the first character of the string.
if (string.trim().isEmpty() || (string == null)) {
    return string;
} else {
    return Character.toUpperCase(string.charAt(0)) + string.substring(1);
StringcapitalizeFirstLetter(String text)
capitalize First Letter
String[] split = text.split(" ");
String finalStr = "";
for (String s : split) {
    finalStr += s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase() + " ";
return finalStr.substring(0, finalStr.length() - 1);
String[]capitalizeFirstLetter(String[] strArr)
capitalize First Letter
for (int j = 0; j < strArr.length; j++) {
    strArr[j] = capitalizeFirstLetter(strArr[j]);
return strArr;
StringcapitalizeFirstOnly(String original)
capitalize First Only
if (original == null) {
    return null;
} else {
    String modified = original.toLowerCase();
    modified = Character.toUpperCase(modified.charAt(0)) + modified.substring(1, modified.length());
    return modified;
StringcapitalizeFirstOnly(String s)
Capitalize all letters preceded by whitespace, and lower case all other letters.
if (s == null)
    return null;
if (s.length() == 0)
    return s;
StringBuffer sbuf = new StringBuffer();
char c = s.charAt(0);
sbuf.append(Character.toUpperCase(c));
boolean space = Character.isWhitespace(c);
...
StringcapitalizeTheFirstLetter(String input)
capitalize The First Letter
String result;
if (input.length() > 0) {
    result = input.substring(0, 1).toUpperCase() + input.substring(1);
} else {
    result = input;
return result;