public class ThrowableTest
{
    //main方法加throws Exception抛出异常,此时异常由运行时捕获
    public static void main(String[] args) throws Exception
    {
        ThrowableA ta = new ThrowableA();
        ta.display();
    }
}
class ThrowableA
{
    int arrays[]= {1,2,3,4,5};
   
    //方法后面加throws Exception,把异常抛出给调用他的方法处理
    public void display() throws Exception
    {
        //此循环会出现一个数组越界的异常
        for(int i=0;i<10;i++)
        {
            System.out.println(arrays[i]);
        }
        System.out.println("This is end line!");
    }
}
//重写方法不允许抛出比被复写方法范围更大的异常