Java - Write code to check if a string is a Valid Dec String

Requirements

Write code to check if a string is a Valid Dec String

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "book2s.com";
        System.out.println(isValidDecString(str));
    }/*www  .  j  av a2 s.  c o m*/

    /**
     * 
     * @param str
     * @return
     */
    public static boolean isValidDecString(String str) {
        char ch;
        for (int i = 0; i < str.length(); i++) {
            ch = str.charAt(i);
            if (ch < '0' || ch > '9')
                return false;
        }
        return true;
    }
}