Here you can find the source of capitalize(final String str)
public static String capitalize(final String str)
//package com.java2s; public class Main { public static String capitalize(final String str) { final char[] buffer = str.toCharArray(); boolean capitalizeNext = true; for (int i = 0; i < buffer.length; i++) { final char ch = buffer[i]; if (capitalizeNext) { buffer[i] = Character.toTitleCase(ch); capitalizeNext = false;// w w w .j a va 2 s . c o m } } return new String(buffer); } }