Java Character isLetter(int codePoint) Method

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

A character is considered to be a letter if its general category type, provided by Character.getType(ch), is any of the following:

  • UPPERCASE_LETTER
  • LOWERCASE_LETTER
  • TITLECASE_LETTER
  • MODIFIER_LETTER
  • OTHER_LETTER

Not all letters have a case. Many characters are letters but are neither uppercase nor lowercase nor title case.

Syntax:

public static boolean isLetter(int codePoint)

Parameters:

The parameter passed is the Unicode codePoint character to be checked for letter.

Returns:

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

Example 1:

Here, the characters are checked whether they are a letter or not.

public class StudyTonight
{  
	public static void main(String[] args)
	{  
		int cp1 = 48;  
		int cp2 = 61;  
		int cp3 = 119;  
		int cp4 = 90;   
		int cp5 = 1232;  

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

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


0 is a letter??: false
= is a letter??: false
w is a letter??: true
Z is a letter??: true
? is a letter??: true

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.isLetter(cp);
			System.out.println((char)cp + " is a  Letter?: "+b);
		}
		catch(Exception e)
		{
			System.out.println("Invalid Input!!");
		}
	}  
}


Enter the Unicode character: 48
0 is a Letter?: false
************************************
Enter the Unicode character: 70
F is a Letter?: true

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.