public class Demo {
public static void main(String[] args) {
String s1 = "123456789";
String s2 = "12345 6789";
System.out.print(isnum(s1));
System.out.print(isnum(s2));
}
public static boolean isnum(String s){
char []ch = s.toCharArray();
for (char c : ch) {
if(!(c > '0' && c <= '9')){
return false;
}
}
return true;
}
}
|
|