Here you can find the source of capitalize(final String str)
private static String capitalize(final String str)
//package com.java2s; //License from project: Apache License public class Main { private static String capitalize(final String str) { final char firstChar = str.charAt(0); final char newChar = Character.toUpperCase(firstChar); if (firstChar == newChar) { // already capitalized return str; }//from w w w.j a va2s . c o m char[] newChars = new char[str.length()]; newChars[0] = newChar; str.getChars(1, str.length(), newChars, 1); return String.valueOf(newChars); } }