Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

java
character
unicode
mapping
communitycreator

What is Character.toTitleCase() in Java?

abhilash

Overview

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.

What is the UnicodeData file?

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.

Syntax

public static boolean isTitleCase(char ch)

Parameters

  • char ch: The character to be checked.

Return value

It returns true if the character is title case. Otherwise it returns false.

Code

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));

    }
}

RELATED TAGS

java
character
unicode
mapping
communitycreator
RELATED COURSES

View all Courses

Keep Exploring