Java String Capitalize capitalize(String string)

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

Description

capitalize

License

Open Source License

Declaration

public static String capitalize(String string) 

Method Source Code

//package com.java2s;

public class Main {
    public static String capitalize(String string) {
        if (string == null)
            throw new NullPointerException("string is null");
        if (string.length() == 0)
            throw new IllegalArgumentException("string is empty");

        if (string.length() == 1) {
            return "" + Character.toUpperCase(string.charAt(0));
        }/*w ww . ja v  a2 s  .co  m*/
        return Character.toUpperCase(string.charAt(0))
                + string.substring(1);
    }
}

Related

  1. capitalize(String string)
  2. capitalize(String string)
  3. capitalize(String string)
  4. capitalize(String string)
  5. capitalize(String string)
  6. capitalize(String string)
  7. capitalize(String string)
  8. capitalize(String string)
  9. capitalize(String string, boolean firstWordOnly)