Java tutorial
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 Actuate Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Actuate Corporation - initial API and implementation *******************************************************************************/ import java.util.HashSet; public class Main { private static final HashSet<Character> splitChar = new HashSet<Character>(); public static String capitalize(String text) { boolean capitalizeNextChar = true; char[] array = text.toCharArray(); for (int i = 0; i < array.length; i++) { Character c = text.charAt(i); if (splitChar.contains(c)) capitalizeNextChar = true; else if (capitalizeNextChar) { array[i] = Character.toUpperCase(array[i]); capitalizeNextChar = false; } } return new String(array); } }