Here you can find the source of capitalize(String words)
public static String capitalize(String words)
//package com.java2s; public class Main { public static String capitalize(String words) { StringBuffer buffer = new StringBuffer(); boolean isNewWord = true; int length = words.length(); for (int i = 0; i < length; ++i) { char c = words.charAt(i); if (Character.isWhitespace(c)) { isNewWord = true;//from www . j a v a2s .c o m } else if (isNewWord) { c = Character.toUpperCase(c); isNewWord = false; } buffer.append(c); } return buffer.toString(); } }