Bonjour,
comment catcher plusieurs exceptions de manière à faire la même chose dans tous les cas d'exceptions sans réécrire plusieurs fois la même chose.
/*
* Created on Aug 23, 2005
*
*/
/**
* @author HackTrack
*
*/
public class DemoException {
public DemoException() {
super();
}
public void demo_1() throws NumberFormatException {
throw new NumberFormatException();
}
public void demo_2() throws Exception {
throw new Exception();
}
public void demo_3() throws ClassCastException {
throw new ClassCastException();
}
public static void main(String[] args) {
DemoException de = new DemoException();
try {
//de.demo_1();
//de.demo_2();
de.demo_3();
} catch (Exception e) {
if (e.getClass().getName().equals("java.lang.Exception")) {
System.out.println("Exception");
} else {
System.out.println("NOT Exception [" + e.getClass().getName() + "]");
}
}
}
}
Combien cela coûte-t-il au total ? Quelles aides apportent l'état et les acteurs du marché pour alléger cette charge non choisie ? Tous les détails sur Commentçamarche.net.