Skip to content

Instantly share code, notes, and snippets.

@tigawa
Created July 19, 2013 23:12
Show Gist options
  • Save tigawa/6043034 to your computer and use it in GitHub Desktop.
Save tigawa/6043034 to your computer and use it in GitHub Desktop.
java7 マルチキャッチ
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