Java Utililty Methods String Capitalize

List of utility methods to do String Capitalize

Description

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

Method

Stringcapitalize(String input)
Capitalizes the input string, converting the first character to upper case.
char first = input.charAt(0);
if (Character.isUpperCase(first))
    return input;
return String.valueOf(Character.toUpperCase(first)) + input.substring(1);
Stringcapitalize(String input)
Capitalizes a string, converting the first character to uppercase.
if (input.length() == 0)
    return input;
return input.substring(0, 1).toUpperCase() + input.substring(1);
Stringcapitalize(String input)
capitalize
int length;
if (input == null || (length = input.length()) == 0) {
    return "";
} else if (length > 1) {
    return input.substring(0, 1).toUpperCase().concat(input.substring(1));
} else {
    return input.toUpperCase();
Stringcapitalize(String input)
Capitalizes the first character of a string.
if (input.isEmpty()) {
    return input;
char first = input.charAt(0);
char capitalized = Character.toUpperCase(first);
return first == capitalized ? input : capitalized + input.substring(1);
Stringcapitalize(String input)
Converts a string such that the first character is upper case.
if (input.length() == 0)
    return input;
char ch = input.charAt(0);
if (Character.isUpperCase(ch))
    return input;
return String.valueOf(Character.toUpperCase(ch)) + input.substring(1);
Stringcapitalize(String inputString)
capitalize
String cap = inputString.toLowerCase().substring(0, 1).toUpperCase();
cap += inputString.toLowerCase().substring(1);
return cap;
Stringcapitalize(String line)
capitalize
StringBuffer sb = new StringBuffer(line);
int size = line.length();
boolean changed = false;
char c;
int lastWordIdx = 0;
for (int i = 0; i < size; i++) {
    i = indexOfNextWord(line, i, lastWordIdx);
    if (i < 0) {
...
Stringcapitalize(String membername)
This method capitalizes the first character in the provided string.
if (trace)
    System.out.println((++cpt) + "\tCapitalize " + membername);
return Character.toUpperCase(membername.charAt(0)) + membername.substring(1);
Stringcapitalize(String message)
Capitalize the first word and trim whitespaces.
message = message.trim();
if (message.equals(""))
    return message;
StringBuilder buffer = new StringBuilder(message);
char first = buffer.charAt(0);
if (!Character.isUpperCase(first))
    buffer.setCharAt(0, Character.toUpperCase(first));
return buffer.toString();
...
Stringcapitalize(String name)
Thus "fooBah" becomes "FooBah" and "X" becomes "X".
if (name.length() == 0) {
    return name;
if (Character.isUpperCase(name.charAt(0))) {
    return name;
char chars[] = name.toCharArray();
char c = chars[0];
...