TP Exceptions
This commit is contained in:
16
DEV2.1/TP10/02_Capture/ArithmeticExceptionApplication.java
Normal file
16
DEV2.1/TP10/02_Capture/ArithmeticExceptionApplication.java
Normal file
@@ -0,0 +1,16 @@
|
||||
public class ArithmeticExceptionApplication {
|
||||
|
||||
public static int division(int a, int b) {
|
||||
// En mettant l'exception ici, on option une ligne de plus à l'exécution
|
||||
return a/b;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
ArithmeticExceptionApplication.division(7, 0);
|
||||
} catch (ArithmeticException e) {
|
||||
System.out.println("Erreur : Division par 0");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user