Java String with only ASCII letter

Description

Java String with only ASCII letter


//package com.demo2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        String s = "";
        int m = 2;
        int n = 2;
        System.out.println(allAlpha(s, m, n));
    }//from  ww w .j ava 2s. c  o m

    public static boolean allAlpha(String s, int m, int n) {
        for (int i = m; i < n; i++)
            if (!isAlpha(s.charAt(i)))
                return false;
        return true;
    }

    public static boolean isAlpha(int c) {
        return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
    }
}



PreviousNext

Related