Write code to check if a char is Alphabet
//package com.book2s; public class Main { public static void main(String[] argv) { char chr = 'a'; System.out.println(isAlphabet(chr)); }/*from ww w . j ava2 s . co m*/ public static boolean isAlphabet(char chr) { return isLowerEnglishCharacter(chr) || isUpperEnglishCharacter(chr); } public static boolean isAlphabet(String str) { for (int index = 0; index < str.length(); index++) { char chr = str.charAt(index); if (!isAlphabet(chr)) { return false; } } return true; } public static boolean isLowerEnglishCharacter(char chr) { int lowerStart = 97;//'a' int lowerEnd = 122;//'z' int code = (int) chr; return code >= lowerStart && code <= lowerEnd; } public static boolean isUpperEnglishCharacter(char chr) { int upperStart = 65;//'A' int upperEnd = 90;//'Z' int code = (int) chr; return code >= upperStart && code <= upperEnd; } }