Files
DEV/DEV2.1/Exception/ex2/ArithmeticExceptionExample.java
2024-03-18 14:28:35 +01:00

15 lines
482 B
Java

public class ArithmeticExceptionExample {
public static void main(String[] args) {
try {
computeDivision(); // Appel de la méthode responsable de l'exception
} catch (ArithmeticException e) {
System.out.println("Une erreur arithmétique s'est produite : " + e.getMessage());
}
}
// Méthode responsable de l'exception
public static void computeDivision() {
int result = 10 / 0; // Division par zéro
}
}