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 pString)
Makes the first letter of a String uppercase.
return capitalize(pString, 0);
Stringcapitalize(String s)
Capitalize a string.
int i = 0;
for (Character c : s.toCharArray()) {
    if (c.charValue() > 96 && c.charValue() < 123) {
        if (i == 0) {
            s = ((char) (c.charValue() - 32)) + s.substring(1);
            return s;
        } else {
            s = s.substring(0, i) + ((char) (c.charValue() - 32)) + s.substring(i + 1);
...
Stringcapitalize(String s)
capitalize
char ch[];
ch = s.toCharArray();
if (ch[0] >= 'a' && ch[0] <= 'z') {
    ch[0] = (char) (ch[0] - 32);
String newString = new String(ch);
return newString;
Stringcapitalize(String s)
Capitalize a word
int len = s.length();
if (len == 0)
    return s;
return new StringBuilder(len).append(Character.toTitleCase(s.charAt(0))).append(s.substring(1)).toString();
Stringcapitalize(String s)
Capitalize the first letter in the word
if (s.length() > 1)
    return s.substring(0, 1).toUpperCase() + s.substring(1);
else if (s.length() == 1)
    return s.toUpperCase();
else
    return s;
Stringcapitalize(String s)
Returns a version of the supplied string with the first letter capitalized.
if (isBlank(s)) {
    return s;
char c = s.charAt(0);
if (Character.isUpperCase(c)) {
    return s;
} else {
    return String.valueOf(Character.toUpperCase(c)) + s.substring(1);
...
Stringcapitalize(String s)
capitalize
return s.substring(0, 1).toUpperCase() + s.substring(1);
Stringcapitalize(String s)
capitalize
return s.isEmpty() ? "" : Character.toUpperCase(s.charAt(0)) + s.substring(1);
Stringcapitalize(String s)
Capitalize a string, producing a valid Java identifier.
StringBuffer n = new StringBuffer();
boolean capitalize = true;
for (int i = 0; i < s.length(); ++i) {
    if (!Character.isLetterOrDigit(n.charAt(i)))
        capitalize = true;
    else {
        n.append(capitalize ? Character.toUpperCase(s.charAt(i)) : s.charAt(i));
        capitalize = false;
...
Stringcapitalize(String s)
/ Returns a capitalized String.
if (isEmpty(s)) {
    return s;
if (s.length() == 1) {
    return "" + Character.toUpperCase(s.charAt(0));
return "" + Character.toUpperCase(s.charAt(0)) + s.substring(1);