Error:程序无法处理的系统错误,编译器不做检查;
Exception:程序可以处理的异常,捕获后可能恢复;
而Exception又可以分为
unchecked exception(非检查异常):不是必须进行try catch的异常
checked exception(检查异常,编译异常,必须要处理的异常) 此类异常要么try catch住,要么往外抛,谁调用,谁处理,比如 FileNotFoundException如果不处理,编译器就不让你通过
常见Error和Exception
unchecked exception:
1、NullPropagation:空指针异常;
2、ClassCastException:类型强制转换异常
3、IllegalArgumentException:传递非法参数异常
4、IndexOutOfBoundsException:下标越界异常
5、NumberFormatException:数字格式异常
checked exception:
1、ClassNotFoundException:找不到指定class的异常
2、IOException:IO操作异常
Error:
1、NoClassDefFoundError:找不到class定义的异常
2、StackOverflowError:深递归导致栈被耗尽而抛出的异常
3、OutOfMemoryError:内存溢出异常