Java Character isTitleCase(int codePoint) Method

Java isTitleCase(int codePoint) is a part of Character class. This method is used to check whether the specified Unicode codepoint character is a Titlecase character or not.

This method also supports supplementary characters. A character is a title case character if its general category type, provided by Character.getType(ch), is TITLECASE_LETTER.

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

Syntax:

public static boolean isTitleCase(int codePoint)

Parameters:

The parameter passed is the Unicode codepoint character to be checked whether it is the title case or not.

Returns:

Returns the boolean value true if the specified character is a title case character else return false.

Example 1:

Here, the characters are checked whether they are title case characters or not.

public class StudyTonight
{  
	public static void main(String[] args)
	{  
		int cp1 = 0x01c8;  
		int cp2 = 60;  
		int cp3 = 119;  
		int cp4 = 0x01c1;   
		int cp5 = 1232;  

		boolean b1 = Character.isTitleCase(cp1);  
		boolean b2 = Character.isTitleCase(cp2);  
		boolean b3 = Character.isTitleCase(cp3);  
		boolean b4 = Character.isTitleCase(cp4);  
		boolean b5 = Character.isTitleCase(cp5);  

		System.out.println((char)cp1 +" is a title case??:  "+b1);  
		System.out.println((char)cp2 +" is a title case??:  "+b2);  
		System.out.println((char)cp3 +" is a title case??:  "+b3);  
		System.out.println((char)cp4 +" is a title case??:  "+b4);  
		System.out.println((char)cp5 +" is a title case??:  "+b5);  
	}  
} 


? is a title case??: true
< is a title case??: false
w is a title case??: false
? is a title case??: false
? is a title case??: false

Example 2:

Here is a user-defined example where anyone using this code can put a value of his choice and get the equivalent output.

import java.util.Scanner; 
public class StudyTonight
{  
	public static void main(String[] args)
	{  
		try
		{
			System.out.print("Enter the Unicode character: ");  
			Scanner sc = new Scanner(System.in);        
			int cp = sc.nextInt(); 
			boolean b = Character.isTitleCase(cp);
			System.out.println((char)cp + " is a title case?: "+b);
		}
		catch(Exception e)
		{
			System.out.println("Invalid Input!!");
		}
	}
}


Enter the Unicode character: 23232
? is a title case?: false
*********************************************
Enter the Unicode character: 112
p is a title case?: false

Live Example:

Here, you can test the live code example. You can execute the example for different values, even can edit and write your examples to test the Java code.