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

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

Java is a popular programming language that is used to develop a wide range of applications. If you are a...
  • Java
  • March 6, 2023
Java is a programming language and computing platform that is used to create various types of applications. It is used...
  • Java
  • March 6, 2023
In this post, you’ll learn how to download and install JUnit in Eclipse so that you can use in your...
  • Java
  • October 9, 2022