Java tutorial
//package com.java2s; public class Main { private static String capitalizeAllWords(String str) { String phrase = ""; boolean capitalize = true; for (char c : str.toLowerCase().toCharArray()) { if (Character.isLetter(c) && capitalize) { phrase += Character.toUpperCase(c); capitalize = false; continue; } else if (c == ' ') { capitalize = true; } phrase += c; } return phrase; } }