throw new ArrayIndexOutOfBoundsException();
public class Launcher {
public static void main(String[] args){
m1();
}
public static void m1(){
m2();
}
public static void m2(){
int[] arr = new int[2];
arr[2] =1;
}
}
public class Launcher {
public static void main(String[] args){
try{
m1();
}catch(ArrayIndexOutOfBoundsException e){
e.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}finally{
System.out.println("finally");
}
}
public static void m1(){
m2();
}
public static void m2(){
int[] arr = new int[2];
arr[2] =1;
}
}
public class MyException extends Exception //继承自Exception
{
public MyException(){
super();
}
public MyException(String msg){
super(msg);
}
}
public static void main(String[] args)throws MyException{
throw new MyException("出现异常了");
}