package demo; public class Isnum { public static void main(String[] args) throws Exception { String num = "123"; System.out.println(isNumber(num)); } public static boolean isNumber(String str) { char [] data = str.toCharArray(); for (int x=0; x<data.length; x++) { if(data[x] > '9' || data[x] < '0') { return false; } } return true; } }