Java String Capitalize capitalizeString(String string)

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

Description

Returns the string defined by parameter string capitalized (the first letter in uppercase).

License

Open Source License

Parameter

Parameter Description
string the string to capitalize

Return

a capitalized string (the first letter in uppercase)

Declaration

public static String capitalizeString(String string) 

Method Source Code

//package com.java2s;
/* IBS Copyright/Security Notice ***************************************
 *                                              
 *  BAP Property of IBS AB/* w w w .j a va2  s . c  om*/
 *  (C) Copyright IBS AB 2001-2003
 *  All rights reserved.                        
 *  Use, duplication, or disclosure restricted  
 *  by license agreement with IBS AB.           
 *                                              
 *  Licensed Materials - Property of IBS AB     
 *                                              
 * End IBS Copyright/Security Notice **********************************
 *
 *
 * User  Date          Comment     
 * ---------------------------------------------------------------------
 * DMA   01/01/2000    Class created
 *  
 ***********************************************************************/

public class Main {
    /**
     * Returns the string defined by parameter <code>string</code> 
     * capitalized (the first letter in uppercase). 
     *
     * @param    string    the string to capitalize
     * @return             a capitalized string (the first letter 
     *                     in uppercase)
     */
    public static String capitalizeString(String string) {
        if (string.length() == 0)
            return string;

        String firstLetter = string.substring(0, 1);
        String theRest = string.substring(1, string.length());
        return firstLetter.toUpperCase() + theRest;

    }
}

Related

  1. capitalizePropertyName(String propertyName)
  2. capitalizePropertyName(String s)
  3. capitalizeString(final String in)
  4. capitalizeString(String aString)
  5. capitalizeString(String str)
  6. capitalizeString(String string)
  7. capitalizeString(String string)
  8. capitalizeString(String text, boolean replaceUnderscore)
  9. capitalizeString(String toCapitalize)