Java - Write code to check if a string is Numeric Space

Requirements

Write code to check if a string is Numeric Space

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "book2s.com";
        System.out.println(isNumericSpace(str));
    }/*from   w w  w  . ja  va2 s  .  c o m*/

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

        int length = str.length();

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

        return true;
    }
}