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

Requirements

Write code to check if a string is Numeric

Demo

//package com.book2s;

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

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

Related Exercise