Signup/Sign In
LAST UPDATED: NOVEMBER 6, 2020

Java Character isAlphabetic() Method

Java isAlphabetic() method is a part of Character class. This method is used to check whether the specified character is an alphabet or not.

A character is considered to be an alphabet if provided by getType(codePoint) has the following characteristics:

  • UPPERCASE_ LETTER
  • LOWERCASE_LETTER
  • TITLECASE_LETTER
  • MODIFIER_LETTER
  • OTHER_LETTER
  • LETTER_NUMBER or
  • Other alphabets defined by the Unicode Standard.

Syntax:

public static boolean isAlphabetic(int codePoint)  

Parameter:

The parameter passed is the Unicode codePoint Character which is to be checked whether it is an alphabet or not.

Returns:

Returns boolean value true if the specified character is an alphabet else return false.

Example 1:

Here, the isAlphabetic() method checks the specified character whether it is an alphabet or not.

public class StudyTonight 
{
	public static void main(String[] args) 
	{
		int cp1 = 56;
		int cp2 = 88;

		boolean b1 = Character.isAlphabetic(cp1);
		boolean b2 = Character.isAlphabetic(cp2);

		System.out.println((char) cp1 + " is alphabet? " + b1);
		System.out.println((char) cp2 + " is alphabet? " + b2);

	}
}


8 is alphabet? false
X is alphabet? true

Example 2:

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

import java.util.Scanner;
public class StudyTonight 
{
	public static void main(String[] args) 
	{
		try 
		{
			System.out.print("Enter Unicode codepoint input: ");
			Scanner sc = new Scanner(System. in );
			int cp = sc.nextInt();
			boolean b = Character.isAlphabetic(cp);

			if (b == true) 
			{
				System.out.println((char) cp + " is an alphabet");
			}
			else 
			{
				System.out.println((char) cp + " is not an alphabet");
			}
		}
		catch(Exception e) 
		{
			System.out.println("Invalid Input!!");
		}
	}
}


Enter Unicode codepoint input: 101
e is an alphabet
*********************************************
Enter Unicode codepoint input: 48
0 is not an alphabet

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.



About the author:
A Computer Science and Engineering Graduate(2016-2020) from JSSATE Noida. JAVA is Love. Sincerely Followed Sachin Tendulkar as a child, M S Dhoni as a teenager, and Virat Kohli as an adult.