✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
division() ci-dessous, attrapez l'exception NumberFormatException. Pour le traitement, relancez la même exception en remplaçant le message attaché par Entrée erronée!.
public static int division(String nb1Str, String nb2Str) {
int div = -1;
try {
int nb1 = Integer.parseInt(nb1Str);
int nb2 = Integer.parseInt(nb2Str);
div = nb1 / nb2;
} catch (ArithmeticException ex) {
System.out.println("Division par zéro");
}
return div;
}
À part la modification du message, y a-t-il d'autres rasions pour lesquelles on voudrait relancer une exception?
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!