Java - Write code to check if a string is Numeric in each character

Requirements

Write code to check if a string is Numeric in each character

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "book2s.com";
        System.out.println(isNumeric(str));
    }// w  w w  .jav  a 2 s.co m

    public static boolean isNumeric(String str) {
        if (str == null) {
            return false;
        }

        int length = str.length();

        for (int i = 0; i < length; i++) {
            if (!Character.isDigit(str.charAt(i))) {
                return false;
            }
        }

        return true;
    }
}