Java - Write code to check if a string is Numeric via for loop and Character.isDigit() method

Requirements

Write code to check if a string is Numeric via for loop and Character.isDigit() method

Demo

import java.util.HashMap;

public class Main{
    public static void main(String[] argv){
        String string = "book2s.com";
        System.out.println(isNumeric(string));
    }//from   ww w.  j  ava2  s .  c  o  m
    public static boolean isNumeric(String string) {
        if (OddStringUtil.isEmpty(string)) {
            return false;
        }
        string = string.trim();
        char[] chars = string.toCharArray();
        for (char C : chars) {
            if (!Character.isDigit(C)) {
                return false;
            }
        }
        return true;
    }
    /**
     * Simply checks if the String is null or has 
     * no non-whitespace characters.
     * @param e
     * @return
     */
    public static boolean isEmpty(String e) {
        return e == null || e.trim().length() == 0;
    }
}

Related Example