Write code to convert spaced separated string to Title Case
import java.util.Collection; import java.util.Enumeration; import java.util.Iterator; import Armadillo.Core.Logger; public class Main{ public static void main(String[] argv){ String input = "abc def"; System.out.println(toTitleCase(input)); }//from w w w. j ava 2 s.com public static String toTitleCase(String input) { StringBuilder titleCase = new StringBuilder(); boolean nextTitleCase = true; for (char c : input.toCharArray()) { if (Character.isSpaceChar(c)) { nextTitleCase = true; } else if (nextTitleCase) { c = Character.toTitleCase(c); nextTitleCase = false; } titleCase.append(c); } return titleCase.toString(); } }