Program to Check whether Character is Alphabet or Not

In this article we are going to write java program to check whether character entered by user is alphabet or not.

Java code to check if character is alphabet or not

package learn;
import java.util.*;
public class AlphabetOrNot {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println("Enter the Character");
		char c =sc.next().charAt(0);
		if((c>= 'a' && c<='z') || (c>= 'A' && c<= 'Z')){
			System.out.println("Alphabet");
		}
		else {
			System.out.println("Not Alphabet");
		}
		
	}

}

Output if character is alphabet

character is alphabet or not

Output if character is not alphabet

alphabet or not in java

Leave a Comment