1.从概念角度分析:
   Error:程序无法处理的系统错误,编译器不做检查;
   Exception:程序可以处理的异常,捕获后可能恢复;
   前者是程序无法处理的错误,后者是可以处理的异常。 
2.从责任角度分析:
   Error:属于JVM需要负担的责任;
   Exception:
       RuntimeException(非受检异常)是程序应该负担的责任;
       Checked Exception (受检异常)可检查异常时Java编译器应该负担的责任。 
3.常见Error和Exception
 
RuntimeException:
   1、NullPointException:空指针异常;
   2、ClassCastException:类型强制转换异常
   3、IllegalArgumentException:传递非法参数异常
   4、IndexOutOfBoundsException:下标越界异常
   5、NumberFormatException:数字类型转换异常
 
非RuntimeException:
   1、ClassNotFoundException:找不到指定class的异常
   2、IOException:IO操作异常
 
Error:
   1、NoClassDefFoundError:找不到class定义的异常
   2、StackOverflowError:深递归导致栈被耗尽而抛出的异常
   3、OutOfMemoryError:内存溢出异常
                
                
                
        
    
转载请注明原文地址:https://ipadbbs.8miu.com/read-60046.html