toTitleCase()
is a static method of the Character
class that transforms a given character to title case through case mapping information from the UnicodeData file.
The uppercase mapping is returned as an equivalent title case mapping if a character has no explicit title case mapping and is not itself a title case character according to the UnicodeData file. The same character will be returned if the character argument is already a title case character.
Character information from the Unicode Standard, especially the UnicodeData file that is part of the Unicode Character Database, is used to construct the fields and methods of the Character
class. For each allocated Unicode code point or character range, this file specifies attributes such as name
and category
.
For more info on Unicode, refer here.
public static boolean isTitleCase(char ch)
char ch
: The character to be checked.It returns true
if the character is title case. Otherwise it returns false
.
In the code below, we use the Character.isTitleCase
method to test whether different characters are in title case.
public class Main {public static void main(String[] args){char ch = 'T';System.out.println( ch + " is titlecase - " + Character.isTitleCase(ch));ch = '\u01f2';System.out.println( ch + " is titlecase - " + Character.isTitleCase(ch));}}