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 s)
Returns a string, where the first letter is converted to upper case and all other letters to lower case.
if (s.length() == 0) {
    return s;
return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
Stringcapitalize(String s)
capitalize
if (s.length() == 0) {
    return s;
} else {
    char ac[] = s.toCharArray();
    ac[0] = Character.toUpperCase(ac[0]);
    return new String(ac);
Stringcapitalize(String s)
Capitalize a string using java bean conventions.
char[] c = s.toCharArray();
c[0] = toUpperCase(c[0]);
return new String(c);
Stringcapitalize(String s)
Returns a string that is equivalent to the specified string with its first character converted to uppercase as by String#toUpperCase .
if (s.length() == 0)
    return s;
char first = s.charAt(0);
char capitalized = Character.toUpperCase(first);
return (first == capitalized) ? s : capitalized + s.substring(1);
Stringcapitalize(String s)
Capitalize a string
if (s == null || s.length() == 0) {
    return s;
char[] ac = { s.charAt(0) };
String f = new String(ac).toUpperCase();
return f + s.substring(1).toLowerCase();
Stringcapitalize(String s)
Capitalizes all the words of a string.
if (s == null)
    return null;
StringBuilder sb = new StringBuilder();
for (String part : s.split("\\s")) {
    part = part.trim();
    if (part.length() == 0)
        continue;
    if (part.length() == 1)
...
Stringcapitalize(String s)
capitalize
int len = s.length();
if (len == 0)
    return s;
else if (len == 1)
    return Character.toUpperCase(s.charAt(0)) + "";
else
    return Character.toUpperCase(s.charAt(0)) + s.substring(1);
Stringcapitalize(String s, char delimiter)
capitalize
boolean capitalize = true;
final char chars[] = s.toCharArray();
for (int i = 0; i < s.length(); i++) {
    chars[i] = capitalize ? Character.toUpperCase(chars[i]) : Character.toLowerCase(chars[i]);
    capitalize = chars[i] == delimiter;
return new String(chars);
Stringcapitalize(String s, String fullstring)
capitalize
s = s.trim();
if (fullstring == null || fullstring.isEmpty()) {
    fullstring = s;
if (fullstring.length() < 3) {
    return s.toUpperCase();
if (s.contains(" ")) {
...
Stringcapitalize(String source)
Ensure that the first character of the provided string is upper case.
if (source == null || source.length() == 0) {
    return source;
if (source.length() > 1 && Character.isUpperCase(source.charAt(0))) {
    return source;
char chars[] = source.toCharArray();
chars[0] = Character.toUpperCase(chars[0]);
...