how to check if a char is a letter java

how to check if a char is a letter java

To check if a char is a letter in Java, you can use the isLetter method of the Character class.

Here's an example of how you might do this:

‮‬refer to:lautturi.com
char ch = 'a';

if (Character.isLetter(ch)) {
    System.out.println("The character is a letter.");
} else {
    System.out.println("The character is not a letter.");
}

In this example, the isLetter method is used to check if the char variable ch is a letter. If it is, the message "The character is a letter." is printed to the console; otherwise, the message "The character is not a letter." is printed.

Created Time:2017-11-01 12:05:13  Author:lautturi