cours/java exceptions.md
Oscar Plaisant 602a41e7f8 update
2024-12-25 22:30:24 +01:00

532 B

up::java title::"gestion des erreurs" #s/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 :