Java String Capitalize capitalize(String input)

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

Description

Capitalizes the first letter of a String .

License

Open Source License

Parameter

Parameter Description
input is the String to capitalize.

Return

the capitalized .

Declaration

public static String capitalize(String input) 

Method Source Code

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

public class Main {
    /**// w  w w  .  j  a  v  a 2  s .co  m
     * Capitalizes the first letter of a {@link String}.
     * @param input is the {@link String} to capitalize.
     * @return the capitalized {@link String}.
     */
    public static String capitalize(String input) {
        if (input == null) {
            throw new IllegalArgumentException("Input string cannot be null!");
        } else if (input.length() < 2) {
            return input.toUpperCase();
        }
        return input.substring(0, 1).toUpperCase() + input.substring(1);
    }
}

Related

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