Java String Capitalize First capitalizeFirst(String str)

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

Description

capitalize First

License

Apache License

Declaration

public static String capitalizeFirst(String str) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String capitalizeFirst(String str) {
        if (str.isEmpty()) {
            return str;
        }/*ww w  .j a v  a 2 s  .c  o m*/

        char firstCh = str.charAt(0);
        char newFirstCh = Character.toUpperCase(firstCh);
        if (firstCh == newFirstCh) {
            return str;
        }

        return newFirstCh + str.substring(1);
    }
}

Related

  1. capitalizeFirst(String rawStr)
  2. capitalizeFirst(String s)
  3. capitalizeFirst(String str)
  4. capitalizeFirst(String str)
  5. capitalizeFirst(String str)
  6. capitalizeFirst(String str)
  7. capitalizeFirst(String str)
  8. capitalizeFirst(String string)
  9. capitalizeFirst(String string)