Program to demonstrate how to check if a character is a letter / alphabet in Java
package com.hubberspot.example; public class IsLetterTest { public static void main(String[] args) { // Create a String of character having letters // in between just for a test String characters = "q1w2E3r4T5y 9$0%a-s^d"; // we take the length of characters by length() int length = characters.length(); // we than loop each character one by one for(int i = 0; i < length; i++) { // we store each character in a variable // for each loop char character = characters.charAt(i); // checking for each character that its a letter or not // by calling Character class isLetter() method , by passing // the character. It returns true if the character passed is // letter or an alphabet if(Character.isLetter(character)) { System.out.println("Given character : " + characters.charAt(i) + " is a letter"); } else { System.out.println("Given character : " + characters.charAt(i) + " is not a letter"); } } } }Output of the program :