Java - Write code to check if a string is Numeric using for loop

Requirements

Write code to check if a string is Numeric using for loop

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "book2s.com";
        System.out.println(isNumeric(str));
    }/*from  w  w w.  j a  v  a2  s . com*/

    public static boolean isNumeric(String str) {
        if (str == null)
            return false;
        int sz = str.length();
        for (int i = 0; i < sz; i++)
            if (!Character.isDigit(str.charAt(i)))
                return false;

        return true;
    }
}

Related Example