java.lang.Character isTitleCase(char ch)

Description

The Character.isTitleCase(char ch) java method determines if the specified character is a titlecase character. A character is a titlecase character if its general category type, provided by Character.getType(ch), is TITLECASE_LETTER.

Some characters look like pairs of Latin letters. For example, there is an uppercase letter that looks like “LJ” and has a corresponding lowercase letter that looks like “lj”. A third form, which looks like “Lj”, is the appropriate form to use when rendering a word in lowercase with initial capitals, as for a book title.

These are some of the Unicode characters for which this method returns true:

  • LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON
  • LATIN CAPITAL LETTER L WITH SMALL LETTER J
  • LATIN CAPITAL LETTER N WITH SMALL LETTER J
  • LATIN CAPITAL LETTER D WITH SMALL LETTER Z

Many other Unicode characters are titlecase too.

This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the isTitleCase(int) method.

The isTitleCase(char ch) method of Character class is static thus it should be accessed statically which means the we would be calling this method in this format:

Character.isTitleCase(char ch)

Non static method is usually called by just declaring method_name(argument) however in this case since the method is static, it should be called by appending the class name as suffix. We will be encountering a compilation problem if we call the java isTitleCase() method non statically.

Method Syntax

public static boolean isTitleCase(char ch)

Method Argument

Data Type Parameter Description
char ch the character to be tested.

Method Returns

The isTitleCase(char ch) method of Character class returns true if the character is titlecase; false otherwise.

Compatibility

Requires Java 1.0.2 and up

Java Character isTitleCase(char ch) Example

Below is a simple java example on the usage of isTitleCase(char ch) method of Character class.

package com.javatutorialhq.java.examples;


/*
 * This example source code demonstrates the use of 
 * isTitleCase(char ch) method of Character class.
 */

public class CharacterIsTitleCaseCharExample {

	public static void main(String[] args) {

		
		// initialize a char
		char value = 'Ñ';
		
		// check if the user input is title case or not
		boolean checkBool = Character.isTitleCase(value);
		// print result
		if(checkBool){
			System.out.print("Value '"+value+"' is Title case");
		}
		else{
			System.out.print("Value '"+value+"' is not Title case");
		}
		
	}

}

Sample Output

Below is the sample output when you run the above example.

java Character isTitleCase(char ch) example output