常见的几种RuntimeException异常如下
NullPointerException//空指针引用异常 ClassCastException//类型强制转换异常 IllegalArgumentException//传递非法参数异常 ArithmeticException//算术运算异常 ArrayStoreException//向数组中存放与声明类型不兼容对象异常 IndexOutOfBoundsException//下标越界异常 NegativeArraySizeException//创建一个大小为负数的数组错误异常 NumberFormatException//数字格式异常 SecurityException//安全异常 UnsupportedOperationException;//不支持的操作异常 NoSuchElementException//无此元素异常 EmptyStackException//空栈异常
RuntimeException是非受检的异常,标识程序出现了异常,是不能恢复的异常。这类异常是由于代码设计不周全,代码本身bug引起。在开发阶段就要尽量避免出现这类异常。