check char is letter by ascii value range - Java java.lang

Java examples for java.lang:char

Description

check char is letter by ascii value range

Demo Code


//package com.java2s;

public class Main {
    /**// w w w.  ja  v a  2 s  .co  m
     * check c is letter
     * 
     * @param c
     * @return
     */
    public static boolean isLetter(char c) {
        return isLower(c) || isUpper(c);
    }

    /**
     * check c is lower letter
     * 
     * @param c
     * @return
     */
    private static boolean isLower(char c) {
        return c >= 97 && c <= 122;
    }

    /**
     * check c is upper letter
     * 
     * @param c
     * @return
     */
    private static boolean isUpper(char c) {
        return c >= 56 && c <= 90;
    }
}

Related Tutorials