Here you can find the source of capitalizeString(String string)
string
capitalized (the first letter in uppercase).
Parameter | Description |
---|---|
string | the string to capitalize |
public static String capitalizeString(String string)
//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; } }