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

StringcapitalizeFirst(String string)
capitalize First
String capitalized = string;
if (string != null && !string.isEmpty()) {
    if (string.length() == 1) {
        return capitalized.toUpperCase();
    } else {
        String stringA = string.substring(0, 1);
        String stringZ = string.substring(1, string.length());
        capitalized = stringA.toUpperCase() + stringZ;
...
StringcapitalizeFirst(String toCap)
capitalize First
String ret = "";
if (null != toCap && toCap.length() > 0) {
    char first = toCap.charAt(0);
    first = Character.toUpperCase(first);
    ret += first;
if (toCap.length() > 1) {
    ret += toCap.substring(1);
...
StringcapitalizeFirst(String toCapitalize)
Make first character of String uppercase, and the rest lowercase.
if (toCapitalize.length() > 1) {
    return toCapitalize.substring(0, 1).toUpperCase()
            + toCapitalize.substring(1, toCapitalize.length()).toLowerCase();
} else {
    return toCapitalize.toUpperCase();
StringcapitalizeFirstChar(final String str)
capitalize First Char
if (str.length() > 1) {
    return str.substring(0, 1).toUpperCase() + str.substring(1);
} else {
    return str.toUpperCase();
StringcapitalizeFirstChar(String name)
capitalize First Char
if (name == null || name.length() == 0) {
    return name;
if (name.startsWith("_")) {
    return capitalizeFirstChar(name.substring(1));
char chars[] = name.toCharArray();
chars[0] = Character.toUpperCase(chars[0]);
...
StringcapitalizeFirstChar(String name)
Capitalize the first character of the name.
if ((name == null) || name.equals("")) {
    return name;
char start = name.charAt(0);
if (Character.isLowerCase(start)) {
    start = Character.toUpperCase(start);
    return start + name.substring(1);
return name;
StringcapitalizeFirstChar(String s)
capitalize First Char
return s.substring(0, 1).toUpperCase() + s.substring(1);
StringcapitalizeFirstCharacter(final String s)
Capitalizes the first character of the given string.
if (s == null) {
    return null;
} else if (s.length() <= 0) {
    return "";
} else {
    return s.substring(0, 1).toUpperCase() + s.substring(1);
StringcapitalizeFirstCharacter(String s)
capitalize First Character
if (s != null) {
    if (s.length() > 1) {
        s = Character.toUpperCase(s.charAt(0)) + s.substring(1);
    } else {
        s = s.toUpperCase();
return s;
...
StringcapitalizeFirstCharacter(String s)
capitalize First Character
if (s != null && s.isEmpty() == false && Character.isLowerCase(s.charAt(0))) {
    return Character.toUpperCase(s.charAt(0)) + s.substring(1);
} else {
    return s;