Untitled
Anonymous
plain_text
08/28/2024 12:35 PM
468 B
16
Indexable
public static void trynumber(int n){ try { checkEvenNumber(n); } catch (IllegalArgumentException e) { System.out.print(e.getMessage()); } } public static void checkEvenNumber(int number) throws IllegalArgumentException { if (number % 2 == 1) throw new IllegalArgumentException("Error: "+number + is odd."); else System.out.print(number+" is even.");Editor is loading...
Leave a Comment