Java String Capitalize First capitalizeFirstCharOfString(final String input)

Here you can find the source of capitalizeFirstCharOfString(final String input)

Description

Capitalizes first char of an input string.

License

Open Source License

Parameter

Parameter Description
input the string to be processed;

Return

The input string with the first capitalized char. Returns empty string, if passed input String is null or empty.

Declaration

static String capitalizeFirstCharOfString(final String input) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/* www. java  2 s .co  m*/
     * Capitalizes first char of an input string.
     *
     * @param input the string to be processed;
     * @return The input string with the first capitalized char. Returns empty string, if passed input String is null or empty.
     */
    static String capitalizeFirstCharOfString(final String input) {
        if (input == null || input.length() == 0) {
            return "";
        } else if (input.length() == 1) {
            return input.toUpperCase();
        } else {
            return input.substring(0, 1).toUpperCase() + input.substring(1);
        }
    }
}

Related

  1. capitalizeFirstCharacter(String str)
  2. CapitalizeFirstCharacter(String Str)
  3. capitalizeFirstCharacter(String value)
  4. capitalizeFirstCharacters(String whole)
  5. capitalizeFirstCharacterString(String item)
  6. capitalizeFirstLeter(String sentence)
  7. capitalizeFirstLetter(final CharSequence chars)
  8. capitalizeFirstLetter(final String aString)
  9. capitalizeFirstLetter(final String s)