zoukankan      html  css  js  c++  java
  • RunnableException与CheckedException

    Checked Exception 编译时异常 编译的时候检查你的代码可能在运行的时候抛出异常,这通常在编译的时候要去处理的。

    RunnableException 运行时异常,可以编译通过,但如果不处理运行时会导致崩溃,需要对其进行try....catch...处理。

    常见的RunnableException 有

    //        int i = 3 / 0;                                  // ArithmeticException ,除数为0时的算法异常
    //        List<String> list = new ArrayList<String>();
    //        String s = list.get(0);                         //IndexOutOfBoundsException,
    //        String [] str = new String[2];
    //        String s = str[3];                              //ArrayIndexOutOfBoundsException
    //        String str = "hello";
    //        str.charAt(5);                                   //StringIndexOutOfBoundsException
    //        Haha haha = null;
    //        haha.sayHello("hello");                          //NullPointerException
    //        Haha haha = new Haha();
    //        haha.sayHello(new Object());                      //IllegalArgumentException(不合法参数)

    //        int i = Integer.parseInt("aa");                   //NumberFormatException
    //        Object o = new Integer(1);
    //        System.out.println((String) o);                     //ClassCastException

  • 相关阅读:
    [转]十步完全理解SQL
    [转]Java日期时间使用总结
    [转]Mybatis出现:无效的列类型: 1111 错误
    [转]java.lang.OutOfMemoryError: PermGen space及其解决方法
    [转]Spring3核心技术之事务管理机制
    [转]Spring的事务管理难点剖析(1):DAO和事务管理的牵绊
    设计模式之装饰模式
    进程通信
    设计模式之备忘录模式
    设计模式之单例模式
  • 原文地址:https://www.cnblogs.com/lianghui66/p/3146093.html
Copyright © 2011-2022 走看看