Let’s see a program to check given character is an alphabet or not in java
package programnew;
import java.util.Scanner;
public class CheckAlphabate {
public static void main(String[] args) {
System.out.println("Enter a character");
Scanner in = new Scanner(System.in);
char c = in.next().charAt(0);
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
System.out.println("the given charecter is alphabet ");
} else {
System.out.println("the given charecter is not alphabet ");
}
}
}
Output is :-
Enter a character
@
the given charecter is not alphabet