Java String Capitalize capitalize(String s)

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

Description

Uppercases the first character of a string.

License

Open Source License

Parameter

Parameter Description
s a string to capitalize

Return

a capitalized version of the string

Declaration

public static String capitalize(String s) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from  w  w w  . j  av  a2s . c o m
     * Uppercases the first character of a string.
     *
     * @param s a string to capitalize
     * @return a capitalized version of the string
     */
    public static String capitalize(String s) {
        if (Character.isLowerCase(s.charAt(0))) {
            return Character.toUpperCase(s.charAt(0)) + s.substring(1);
        } else {
            return s;
        }
    }
}

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)