String str = "hello world"; char firstChar = str.charAt(0); char titleCaseChar = Character.toTitleCase(firstChar); System.out.println("Title case character: " + titleCaseChar);
Title case character: H
String name = "JOHN"; char firstChar = name.charAt(0); char titleCaseChar = Character.toTitleCase(firstChar); String newName = titleCaseChar + name.substring(1).toLowerCase(); System.out.println("New name: " + newName);
New name: JohnThe Character class is part of the Java.lang package.