Program to check given character is an alphabet or not in java
import java.util.Scanner;
public class AlphabetOrNot
{
public static void main(String args[])
{
//create and initialize object.
char ch;
Scanner scan = new Scanner(System.in);
//Input character
System.out.print("Enter a Character : ");
ch = scan.next().charAt(0);
//condition for checking characters.
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
First run:
Enter a Character : A
A is an Alphabet
Second run:
Enter a Character : @
@ is not an Alphabet
Program to check given character is an alphabet or not in java
Output
need an explanation for this answer? contact us directly to get an explanation for this answer