This commit is contained in:
2024-03-18 14:28:35 +01:00
parent a28bef01d7
commit cd3133cbe1
8 changed files with 90 additions and 37 deletions

View File

@@ -0,0 +1,14 @@
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
}
}

View File

@@ -0,0 +1,9 @@
public class Main {
public static void main(String[] args) {
try {
ArithmeticExceptionVrai.computeDivision();
} catch (ArithmeticException e) {
System.out.println("Une erreur arithmétique s'est produite : " + e.getMessage());
}
}
}