Java program to check whether a character is alphabet or not

Here's a Java program to check whether a character is an alphabet or not:

public class CharacterCheck {
    public static void main(String[] args) {
        char ch = 'a';

        if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) {
            System.out.println(ch + " is an alphabet");
        } else {
            System.out.println(ch + " is not an alphabet");
        }
    }
}
Source:‮www‬.theitroad.com

In this program, we declare a char variable ch and assign it a value of 'a'. We then use an if statement to check whether the character is an alphabet or not. We do this by checking whether the character is within the range of lowercase and uppercase letters in the ASCII table.

If the character is within this range, we print a message saying that it is an alphabet. Otherwise, we print a message saying that it is not an alphabet.

You can replace the character assigned to ch with any other character that you want to check whether it's an alphabet or not.