2016-06-30
Error:Java运行时的内部错误以及资源耗尽错误,很难恢复,不期望用户来处理。
Throwable
Error
Exception
RuntimeException:运行时异常
非RuntiemException:由环境因素导致
package com.java1995; public class ClassCastExceptionTest { public static void main(String[] args) { // String a="123a"; // int b=Integer.parseInt(a); People p1=new Student(); Student s1=(Student)p1; /** * 空指针异常NullPointerException */ // s1=null; // s1.run(); /** * 类型转换异常ClassCastException */ // Teacher t1=(Teacher)p1; /** * 数组越界异常ArrayIndexOutOfBoundsException */ // int[] arr=new int[]{1,2,3}; // int temp=arr[5]; } } class People{ } class Student extends People{ private String name; private int age; public void run(){ System.out.println("跑吧"); } } class Teacher extends People{ }
【参考资料】