Java String Capitalize capitalize(String s)

Here you can find the source of capitalize(String s)

Description

capitalize.

License

Open Source License

Parameter

Parameter Description
s String

Return

String

Declaration

public static String capitalize(String s) 

Method Source Code

//package com.java2s;

public class Main {
    /**/* w w w.  ja  va 2s . c  om*/
     * capitalize.
     * @param s String
     * @return String
     */
    public static String capitalize(String s) {
        if (isEmpty(s)) {
            return s;
        }
        return Character.toTitleCase(s.charAt(0)) + s.substring(1);
    }

    /**
     * whether or not the string is null or consists only of whitespace. 
     * @param s 
     * @return boolean
     * */
    public static boolean isEmpty(String s) {
        return s == null || s.trim().length() == 0;
    }
}

Related

  1. capitalize(String s)
  2. capitalize(String s)
  3. capitalize(String s)
  4. capitalize(String s)
  5. capitalize(String s)
  6. capitalize(String s)
  7. capitalize(String s)
  8. capitalize(String s)
  9. capitalize(String s)