Javatpoint Logo
Javatpoint Logo

Java Character toTitleCase() Method

The toTitleCase(char ch) method of Character class converts the given character argument to the titlercase using a case mapping information which is provided by the Unicode Data file. It should be noted that Character.isTitleCase(Character.TitleCase(ch)) may not always return true for some characters.

It has been seen that if a character has no explicit titlecase mapping and is not a titlecase character as per the Unicode Data file, then an uppercase mapping is returned. On the other hand, if the character argument is already a titlecase character, then the same value will be returned.

Syntax

Parameter

ch: It is the character that needs to be converted.

Return Value

The toTitleCase(char ch) method returns the titlecase of the given character. Otherwise, this method returns the character itself.

Example 1

Test it Now

Output:

The titlecase of character 'b' is given as: B
The titlecase of character 'm' is given as: M

Example 2

Test it Now

Output:

The titlecase of character ')' is given as: )
The titlecase of character 'G' is given as: G

Java Character toTitleCase()Method

The toTitleCase(int codePoint) method of Character class converts the given character(Unicode code point) argument to the titlercase using a case mapping information which is provided by the Unicode Data file.

It should be noted that Character.isTitleCase(Character.TitleCase(codePoint)) may not always return true for some characters.

It has been seen that if a character has no explicit titlecase mapping and is not a titlecase character as per the Unicode Data file, then an uppercase mapping is returned. On the other hand, if the character argument is already a titlecase character, then the same value will be returned.

Syntax

Parameter

codePoint: It is the codePoint which is the character that needs to be tested.

Return Value

The toTitleCase(int codePoint) method returns the titlecase of the given character(Unicode code point). Otherwise, this method returns the character itself.

Example 1

Test it Now

Output:

The titlecase for the character '153' isgiven as: 153
The titlecase for the character '128' isgiven as: 128

Example 2

Test it Now

Output:

The titlecase for the character '273' isgiven as: 272
The titlecase for the character '156' isgiven as: 156
Next TopicJava Character




Please Share

facebook twitter google plus pinterest