Java String Capitalize capitalize(String str)

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

Description

Capitalize given string by transforming the first character to upper case.

License

Open Source License

Parameter

Parameter Description
str the string.

Return

the capitalized string.

Declaration

public static String capitalize(String str) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from w w w.j  a  v  a  2  s  . c o m
     * Capitalize given string by transforming the first character to upper case.
     * 
     * @param str the string.
     * @return the capitalized string.
     */
    public static String capitalize(String str) {
        StringBuilder buff = new StringBuilder(str.length());
        buff.append(Character.toUpperCase(str.charAt(0)));
        buff.append(str.substring(1));
        return buff.toString();
    }
}

Related

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