Java String Upper Case toUppercaseFirstLetter(String str)

Here you can find the source of toUppercaseFirstLetter(String str)

Description

to Uppercase First Letter

License

Open Source License

Declaration

public static String toUppercaseFirstLetter(String str) 

Method Source Code

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

public class Main {
    public static String toUppercaseFirstLetter(String str) {
        if (str == null || str.length() == 0) {
            return str;
        }/*from   w  w  w .j  a  va  2s  . c  om*/

        char firstLetter = str.charAt(0);
        if (Character.isLowerCase(firstLetter)) {

            if (str.length() > 1) {
                return "" + Character.toUpperCase(firstLetter) + str.substring(1);
            } else {
                return "" + Character.toUpperCase(firstLetter);
            }

        } else {
            return str;
        }
    }
}

Related

  1. toUpperCaseFirstChar(String string)
  2. toUpperCaseFirstChar(String text)
  3. toUppercaseFirstCharacter(String s)
  4. toUpperCaseFirstCharacter(String str)
  5. toUpperCaseFirstCharForWord(String string)
  6. toUpperCaseFirstLetter(String str)
  7. toUpperCaseFirstLetter(StringBuilder sb)
  8. toUpperCaseFirstOne(String origin)
  9. toUpperCaseFirstOne(String s)