Here you can find the source of capitalize(String str)
public static String capitalize(String str)
//package com.java2s; //License from project: Apache License public class Main { /**//from ww w.j a v a 2 s . c o m * <p/> * Capitalizes a String changing the first letter to title case as per {@link Character#toTitleCase(char)}. */ public static String capitalize(String str) { String capilizedStr = str; int len; if (str != null && (len = str.length()) > 0) { capilizedStr = new StringBuilder(len).append(Character.toTitleCase(str.charAt(0))) .append(str.substring(1)).toString(); } return capilizedStr; } }