如下是常见的 Error 和 Exception:
1)运行时异常(RuntimeException)也称 【非检查型异常 UncheckedException】:
- Nullpointer Exception:空指针异常;
- ClassCastException:类型强制转换异常
- IllegalArgumentException:传递非法参数异常
- IndexOutOfBoundsException:下标越界异常
- NumberFormatException:数字格式异常
- ArrayIndexOutOfBoundsException: 数组越界异常
- ArrayStoreException: 数据存储异常,操作数组时类型不一致
- ArithmeticException: (算术异常)
- BufferOverflowException: (缓冲区溢出异常)
2)非运行时异常(CheckedException)也称 【检查型异常】:
- ClassNotFoundException:找不到指定 class 的异常
- IOException:IO 操作异常
- FileNotFoundException:文件不存在异常
- SQLException:SQL语句异常
- InterruptedException: (中断异常-调用线程睡眠时候)
3)错误(Error):
- NoClassDefFoundError:找不到 class 定义异常
- StackOverflowError:深递归导致栈被耗尽而抛出的异常
- OutOfMemoryError:内存溢出异常