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

CharSequencecapitalize(CharSequence s)
capitalize
if (isNotBlank(s) && !Character.isUpperCase(s.charAt(0))) {
    final StringBuilder sb = new StringBuilder(s);
    sb.setCharAt(0, Character.toUpperCase(s.charAt(0)));
    return sb.toString();
return s;
Stringcapitalize(CharSequence s)
capitalize
if (null == s)
    return null;
int len = s.length();
if (len == 0)
    return "";
char char0 = s.charAt(0);
if (Character.isUpperCase(char0))
    return s.toString();
...
Stringcapitalize(final String docName)
Capitalize initial letters in a document name.
char[] chars = docName.toLowerCase().toCharArray();
boolean isInitial = true;
for (int i = 0; i < chars.length; i++) {
    if (isInitial && Character.isLetter(chars[i])) {
        chars[i] = Character.toUpperCase(chars[i]);
        isInitial = false;
    } else {
        isInitial = !Character.isLetter(chars[i]);
...
Stringcapitalize(final String input)
Return the input string with the first character converted to upper case.
String result = input;
if (input != null && input.length() > 0) {
    result = input.substring(0, 1).toUpperCase();
    if (input.length() > 1) {
        result += input.substring(1);
return result;
...
Stringcapitalize(final String name)
capitalize
String s = name;
if (s != null && s.length() > 0) {
    StringBuffer sb = new StringBuffer(s.length());
    sb.append(s.substring(0, 1).toUpperCase());
    if (s.length() > 1) {
        sb.append(s.substring(1, s.length()));
    s = sb.toString();
...
Stringcapitalize(final String s)
Capitalizes the first character of the specified string, and de-capitalize the rest of characters.
if (!isLower(s.charAt(0))) {
    return s;
StringBuilder sb = new StringBuilder(s.length());
sb.append(Character.toUpperCase(s.charAt(0)));
sb.append(s.substring(1).toLowerCase());
return sb.toString();
Stringcapitalize(final String s)
capitalize
int i = s.length();
if (i > 0) {
    char c1 = s.charAt(i);
    if (c1 > LIM_ST_LCASE && c1 < LIM_N_LCASE) {
        char c2 = UCASE[c1];
        if (c1 != c2) {
            char[] c = s.toCharArray();
            c[i] = c2;
...
Stringcapitalize(final String s)
Return a capitalized version of the specified property name.
String cs = null;
if (s != null && 0 < s.length()) {
    final char[] chars = s.toCharArray();
    chars[0] = Character.toUpperCase(chars[0]);
    cs = new String(chars);
return cs;
Stringcapitalize(final String s)
Capitalizes the first letter of the specified string and makes the rest lowercase.
if (s.length() == 0) {
    return s;
return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
Stringcapitalize(final String s)
Capitalizes the provided string.
return capitalize(s, false);