/** * * Utilisation d'une exception qui est loint d'être levée! * @author Mohamed Lokbani * @version 1.1 */ import java.io.*; // nécessaire pour le IOException public class exo1 { public static int divint (int x, int y) { return (x/y); } static void main (String [] args) { int c=0,a=1,b=0; try { c= divint(a,b); } catch (IOException e) { System.out.println("Erreur a été capturée"); } System.out.println("res: " + c); System.exit(0); } } /* exo1.java:21: exception java.io.IOException is never thrown in body of corresponding try statement catch (IOException e) { On tente d'attraper une exception qui ne sera pas levée dans le bloc try! */