public static void main(String args[]) {
Scanner scnr = new Scanner(System.in);
String number = scnr.next();
try {
if (number.length() > 5) {
throw new IllegalArgumentException();
}
Integer.parseInt(number);
} catch (NumberFormatException | IllegalArgumentException e) {
e.printStackTrace();
}
}
Scanner scnr = new Scanner(System.in);
String number = scnr.next();
try {
if (number.length() > 5) {
throw new IllegalArgumentException();
}
Integer.parseInt(number);
} catch (NumberFormatException | IllegalArgumentException e) {
e.printStackTrace();
}
}
No comments:
Post a Comment
Post a Comment
Note: Only a member of this blog may post a comment.