Code Library

Code Library >> Java

Propercase Function

Description: Converts string to proper case.
Submitted: 04/27/2004

Source Code:
public static String getProperCase(String inString) { //capitalizes first letter of every word String curChr = ""; String prevChr = " "; String outString = ""; for(int i = 1; i < inString.length(); i++) { if (prevChr == " ") { outString = outString + curChr.toUpperCase(); } else { outString = outString + curChr.toLowerCase(); } prevChr = curChr; } return outString; }