Here you can find the source of capitalize(String string)
public static String capitalize(String string)
//package com.java2s; public class Main { public static String capitalize(String string) { if (string == null) throw new NullPointerException("string is null"); if (string.length() == 0) throw new IllegalArgumentException("string is empty"); if (string.length() == 1) { return "" + Character.toUpperCase(string.charAt(0)); }/*w ww . ja v a2 s .co m*/ return Character.toUpperCase(string.charAt(0)) + string.substring(1); } }