Created
July 19, 2013 23:12
-
-
Save tigawa/6043034 to your computer and use it in GitHub Desktop.
java7 マルチキャッチ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Multcatch { | |
public static void main(String[] args) { | |
String s = "a"; | |
try{ | |
exception(s); | |
} catch(AException | BException e){ | |
System.out.println("Exception"); | |
} | |
} | |
public static void exception(String s) throws AException, BException{ | |
switch(s){ | |
case "a": throw new AException(); | |
case "b": throw new BException(); | |
} | |
} | |
/** 例外クラス*/ | |
public class AException extends Exception {} | |
/** 例外クラス*/ | |
public class BException extends Exception {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment