Java Program to Check if a Character is an Alphabet or not

In this Java tutorial, you’ll learn how to Check if a Character is an Alphabet or not using Java programming language

How to Check if a character is an Alphabet or not? 

In this program, we’ll learn how to Check if a Character is an Alphabet or not through the JAVA program.   

RUN CODE SNIPPET
import java.util.Scanner; 
public class Main 
{ 
     public static void main(String []args) 
     { 
        Scanner sc=new Scanner(System.in); 
        char ch;      
        System.out.println("Enter the character "); 
        ch=sc.next().charAt(0);    
        if((ch>='A' && ch<='Z')||(ch>='a' && ch<='z')) 
        { 
             System.out.print(ch+" is an Alphabet "); 
        } 
        else 
        { 
             System.out.print(ch+" is not an Alphabet "); 
        } 
     }    
}

OUTPUT 

Enter the character Z 
Z is an Alphabet

In the above program, we have used if. Else statement to check if a character is an alphabet or not. 

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this Java program, we will learn how to find the GCD of two numbers using Java.  GCD (Greatest Common...
  • Java
  • December 3, 2024
In this Java Program, you’ll learn how to swap two numbers using the Java programming language.  How to Swap Two...
  • Java
  • December 2, 2024
In this Java program , we will learn how to Find Largest Element in an Array in your Java program.   How to Find Largest Element...
  • Java
  • December 2, 2024