Java String Capitalize First capitalizeFirst(String toCapitalize)

Here you can find the source of capitalizeFirst(String toCapitalize)

Description

Make first character of String uppercase, and the rest lowercase.

License

Open Source License

Declaration

public static String capitalizeFirst(String toCapitalize) 

Method Source Code

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

public class Main {
    /**//www  .j  a  v  a2  s .c om
     * Make first character of String uppercase, and the
     * rest lowercase.
     */
    public static String capitalizeFirst(String toCapitalize) {
        if (toCapitalize.length() > 1) {
            return toCapitalize.substring(0, 1).toUpperCase()
                    + toCapitalize.substring(1, toCapitalize.length()).toLowerCase();
        } else {
            return toCapitalize.toUpperCase();
        }

    }
}

Related

  1. capitalizeFirst(String str)
  2. capitalizeFirst(String str)
  3. capitalizeFirst(String string)
  4. capitalizeFirst(String string)
  5. capitalizeFirst(String toCap)
  6. capitalizeFirstChar(final String str)
  7. capitalizeFirstChar(String name)
  8. capitalizeFirstChar(String name)
  9. capitalizeFirstChar(String s)