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 { public static String capitalize(String str) { if (isEmpty(str)) return str; char[] cs = str.toCharArray(); cs[0] = Character.toUpperCase(cs[0]); return new String(cs); }//w w w . j a v a2 s . co m public static boolean isEmpty(String str) { return str == null || str.length() == 0; } }