public static void main(String[] args) {
String a= "";
System.out.println(isNumeric(a));
System.out.println(isNumber(a));
}
public static boolean isNumeric(String string) {
return string.matches("\\d+");
}
public static boolean isNumber(String string) {
for (int i = 0; i < string.length(); i++) {
if (!Character.isDigit(string.charAt(i)))
return false;
}
return true;
}
No comments:
Post a Comment