logo

Crowdly

Dans la fonction division() ci-dessous, attrapez l'exception NumberFormatExce...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Dans la fonction 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?

More questions like this

Want instant access to all verified answers on cmontmorency.moodle.decclic.qc.ca?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!