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 string)
Capitalizes the first letter of a String.
if (isEmpty(string))
    return (string);
if (string.length() == 1)
    return (string.toUpperCase());
return (string.substring(0, 1).toUpperCase() + string.substring(1, string.length()));
Stringcapitalize(String string)
Capitalizes the first character of a String.
return isNullOrEmpty(string) ? string
        : string.substring(0, 1).toUpperCase() + string.substring(1).toLowerCase();
Stringcapitalize(String string)
Method that converts first char of given string to upper case and rest of charts - to lower case.
String result;
if (!isHollow(string)) {
    string = string.toLowerCase();
    result = Character.toUpperCase(string.charAt(0)) + string.substring(1);
} else
    result = "";
return result;
Stringcapitalize(String string)
Capitalize the first letter of a string.
if (string == null) {
    return null;
} else if (string.length() == 0) {
    return string;
} else {
    char[] chars = string.toCharArray();
    chars[0] = Character.toUpperCase(chars[0]);
    return new String(chars);
...
Stringcapitalize(String string)
capitalize
if (string == null) {
    return null;
} else if (string.length() == 0) {
    return "";
} else if (Character.isUpperCase(string.charAt(0))) {
    return string;
} else {
    char[] chars = string.toCharArray();
...
Stringcapitalize(String string)
Returns the specified string with its first character converted to upper case.
int length = string.length();
if (length == 0) {
    return string;
} else if (length == 1) {
    return string.toUpperCase();
} else {
    return (Character.toUpperCase(string.charAt(0)) + string.substring(1));
Stringcapitalize(String string)
Return (possibly copy of) given string with first character upper case.
if (Character.isUpperCase(string.charAt(0)))
    return string;
char chars[] = string.toCharArray();
chars[0] = Character.toUpperCase(chars[0]);
return new String(chars);
Stringcapitalize(String string)
capitalize
if (string == null || string.length() == 0)
    return string;
String first = string.substring(0, 1).toUpperCase();
if (string.length() == 1)
    return first;
return first + string.substring(1);
Stringcapitalize(String string)
Capitalize string.
if (string == null || string.isEmpty()) {
    return string;
int index = 0, length = string.length();
while (index < length - 1) {
    if (Character.isAlphabetic(string.charAt(index))) {
        break;
    ++index;
if (index == length) {
    return string;
} else {
    StringBuilder builder = new StringBuilder();
    builder.append(string.substring(0, index));
    builder.append(Character.toUpperCase(string.charAt(index)));
    builder.append(string.substring(index + 1));
    return builder.toString();
Stringcapitalize(String string)
Converts the string to capitalized.
StringBuffer result = new StringBuffer(toCamelCase(string));
result.replace(0, 1, "" + Character.toUpperCase(result.charAt(0))); 
return result.toString();