Here you can find the source of capitalize(String string)
public static String capitalize(String string)
//package com.java2s; //License from project: Open Source License public class Main { public static String capitalize(String string) { char[] letters = string.toCharArray(); for (int index = 0; index < letters.length; index++) { if (index != 0 && !Character.isWhitespace(letters[index - 1])) continue; if (!Character.isLowerCase(letters[index])) continue; letters[index] = Character.toUpperCase(letters[index]); }/*from w ww . j av a 2 s. c om*/ return new String(letters); } }