Java String Capitalize capitalize(final String str)

Here you can find the source of capitalize(final String str)

Description

capitalize the first letter of a string

License

Open Source License

Parameter

Parameter Description
str the string to capitalize

Return

the capitalized version.

Declaration

public static String capitalize(final String str) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from ww w  .  j  a  v  a2 s  .co m*/
     * capitalize the first letter of a string
     * 
     * @param str
     *            the string to capitalize
     * @return the capitalized version.
     */
    public static String capitalize(final String str) {
        if (str == null) {
            return str;
        }
        int strLen = str.length();
        if (strLen == 0) {
            return str;
        }
        return new StringBuilder(strLen).append(Character.toTitleCase(str.charAt(0))).append(str.substring(1))
                .toString();
    }
}

Related

  1. capitalize(final String str)
  2. capitalize(final String str)
  3. capitalize(final String str)
  4. capitalize(final String str)
  5. capitalize(final String str)
  6. capitalize(final String str, final char... delimiters)
  7. capitalize(final String text)
  8. capitalize(final String value)
  9. capitalize(final String value)