codescracker


java

Java Program to Check Alphabet or Not



« Previous Program Next Program »


Check Alphabet or Not in Java

To check whether the entered character is an alphabet or not an alphabet in Java programming, you have to ask to the user to enter a character and start checking for alphabet.

If the character is in between a to z(will be alphabet) or A to Z(will also be alphabet) otherwise it will not be an alphabet.

Java Programming Code to Check Alphabet or Not

Following Java Program ask to the user to enter a character to check whether it is an alphabet or not, then display the output on the screen:

/* Java Program Example - Check Alphabet or Not */
		
import java.util.Scanner;

public class JavaProgram
{
    public static void main(String args[])
    {
        char ch;
        Scanner scan = new Scanner(System.in);
		
        System.out.print("Enter a Character : ");
        ch = scan.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");
        }
    }
}

When the above Java Program is compile and executed, it will produce the following output. Above Java Programming Example Output (for alphabet - lowercase):

Java Program check alphabet

Above Java Programming Example Output (for alphabet - uppercase):

Java Program find alphabet

Above Java Programming Example Output (for not alphabet - number):

check alphabet in java

Above Java Programming Example Output (for not alphabet - special character):

check character is alphabet or not in java

Same Program in Other Languages

You may also like to learn and practice the same program in other popular programming languages:


« Previous Program Next Program »


Latest 5 Posts by CodesCracker



Tools
Calculator

Quick Links
Signup - Login - Give Online Test