Java String Capitalize First capitalizeFirstLetter(String message)

Here you can find the source of capitalizeFirstLetter(String message)

Description

Capitalizes the first letter of the message and returns the result.

License

Open Source License

Parameter

Parameter Description
message The message to convert.

Return

The converted message, or null if the argument is null.

Declaration

public static final String capitalizeFirstLetter(String message) 

Method Source Code

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

public class Main {
    /**/*from   w w w .  ja  va  2 s  .co  m*/
     * Capitalizes the first letter of the message and returns the result. If
     * the argument is null, then null is returned. If the first letter is
     * capitalized this will return an identical string. If the string is empty
     * then it will return the same empty string back.
     * 
     * @param message The message to convert.
     * 
     * @return The converted message, or null if the argument is null.
     */
    public static final String capitalizeFirstLetter(String message) {
        if (message == null || message.length() == 0) {
            return message;
        }

        char firstUpperCaseLetter = Character.toUpperCase(message.charAt(0));
        String remainderOfMessage = message.substring(1);
        return firstUpperCaseLetter + remainderOfMessage;
    }
}

Related

  1. capitalizeFirstLetter(final String s)
  2. capitalizeFirstLetter(final String variableName)
  3. capitalizeFirstLetter(String data)
  4. capitalizeFirstLetter(String data)
  5. capitalizeFirstLetter(String data)
  6. CapitalizeFirstLetter(String name)
  7. capitalizeFirstLetter(String s)
  8. capitalizeFirstLetter(String s)
  9. capitalizeFirstLetter(String s)