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 name)
capitalize
if (name == null || name.length() == 0) {
    return name;
return name.substring(0, 1).toUpperCase() + name.substring(1);
Stringcapitalize(String name)
Capitalize the input name.
if (name == null || name.isEmpty()) {
    return name;
} else {
    return Character.toUpperCase(name.charAt(0)) + name.substring(1);
Stringcapitalize(String name)
Utility method to take a string and convert it to normal a string with the first character in upper case.
if (name == null || name.length() == 0) {
    return name;
char chars[] = name.toCharArray();
chars[0] = Character.toUpperCase(chars[0]);
return new String(chars);
Stringcapitalize(String name)
This method capitalizes the first character in the provided string.
int len = name.length();
StringBuffer sb = new StringBuffer(len);
boolean setCap = true;
for (int i = 0; i < len; i++) {
    char c = name.charAt(i);
    if (c == '-' || c == '_') {
        setCap = true;
    } else {
...
Stringcapitalize(String name)
Converts a property name to class name according to the JavaBean convention
return name.substring(0, 1).toUpperCase() + name.substring(1);
Stringcapitalize(String name)
Uppercases the first character of a string.
if (name != null && name.length() > 0) {
    char c = name.charAt(0);
    if (Character.isLowerCase(c)) {
        StringBuffer sb = new StringBuffer(name);
        sb.setCharAt(0, Character.toUpperCase(c));
        name = sb.toString();
return name;
Stringcapitalize(String name)
capitalize
int[] codePoints = name.codePoints().toArray();
if (Character.isLetter(codePoints[0])) {
    codePoints[0] = Character.toUpperCase(codePoints[0]);
return new String(codePoints, 0, codePoints.length);
Stringcapitalize(String orig)
capitalize
StringBuffer buf = new StringBuffer(orig);
for (int i = 0; i < orig.length(); i++) {
    if (i == 0 || orig.charAt(i - 1) == ' ') {
        if (Character.isLowerCase(orig.charAt(i))) {
            buf.setCharAt(i, Character.toUpperCase(orig.charAt(i)));
String r = new String(buf);
return r;
Stringcapitalize(String original)
capitalize
if (original.length() < 1) {
    throw new IllegalArgumentException("This string is empty");
} else if (original.length() == 1) {
    return original.toUpperCase();
} else {
    return original.substring(0, 1).toUpperCase() + original.substring(1);
Stringcapitalize(String propertyName)
capitalize
return propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1);