Here you can find the source of capitalizeFirstCharacter(String str)
Parameter | Description |
---|---|
str | The String to convert to lower case then capitalized the first character. |
public static String capitalizeFirstCharacter(String str)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w. java 2 s . c om * Returns the given String in lower case with the first character capitalized. * * @param str The String to convert to lower case then capitalized the first character. * * @return The given String in lower case with the first character capitalized. */ public static String capitalizeFirstCharacter(String str) { if (str == null) throw new IllegalArgumentException("Parameter 'str' cannot be null!"); if (str.length() <= 0) return ""; str = str.toLowerCase(); StringBuilder sb = new StringBuilder(); sb.append(Character.toUpperCase(str.charAt(0))); sb.append(str.substring(1)); return sb.toString(); } }