Here you can find the source of capitalize(final String word)
public static String capitalize(final String word)
//package com.java2s; //License from project: Open Source License public class Main { public static String capitalize(final String word) { char chars[] = word.toCharArray(); if (chars.length >= 1) { chars[0] = Character.toUpperCase(chars[0]); }/*from ww w. j av a 2 s .c o m*/ if (chars.length >= 2) { for (int i = 1; i < chars.length; i++) { if (chars[i - 1] == ' ' || chars[i - 1] == '\'' || chars[i - 1] == '-') { chars[i] = Character.toUpperCase(chars[i]); } } } return String.valueOf(chars); } }