cours/java exceptions.md
oscar.plaisant@icloud.com 38fbb1938d from github to this gitea
2023-10-23 23:09:51 +02:00

530 B

up::java title::"gestion des erreurs" #informatique


Gestion des erreurs avec java.

  • détections / traitement des erreurs
    • try catch et finally

Détection d'erreurs

public class TextException {
    public static void main(String[] args) {
        int i = 1;
        int j = 0;

        try {
            System.out.println("resultat = " + (i/j));
        } catch (ArithmeticException e) {
            System.out.println("division par 0");
        }
    }
}

Avec throws :