[Java] catcher plusieurs exceptions
Résolu
jebok
Messages postés
358
Date d'inscription
Statut
Membre
Dernière intervention
-
Utilisateur anonyme -
Utilisateur anonyme -
A voir également:
- [Java] catcher plusieurs exceptions
- Waptrick java football - Télécharger - Jeux vidéo
- Jeux java itel - Télécharger - Jeux vidéo
- Atube catcher - Télécharger - Copie & Extraction
- Eclipse java - Télécharger - Langages
- Java apk - Télécharger - Langages
5 réponses
salut
faire jouer l'héritage en créant une Exception dont tes deux exception seraient les descendants
faire jouer l'héritage en créant une Exception dont tes deux exception seraient les descendants
Pour tester, met les différents appels de.demo_1(), de.demo_2() et de.demo_3() en commentaire
;-)
HackTrack
/* * 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() + "]"); } } } }
;-)
HackTrack
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question