Java String with only ASCII digit

Description

Java String with only ASCII digit


//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(allDigit(s, m, n));
    }//from w  w  w .  j a va 2s. com

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

    public static boolean isDigit(int c) {
        return '0' <= c && c <= '9';
    }
}



PreviousNext

Related