Mega Code Archive

 
Categories / Java Tutorial / Data Type
 

Makes the first letter caps and the rest lowercase

public class Main {   /**    *     *  Makes the first letter caps and the rest lowercase.    *     *    *     *  For example <code>fooBar</code> becomes <code>Foobar</code>.    *     *    * @param data capitalize this    * @return String    */   static public String firstLetterCaps ( String data )   {       String firstLetter = data.substring(0,1).toUpperCase();       String restLetters = data.substring(1).toLowerCase();       return firstLetter + restLetters;   } }