java异常——Exception、RuntimException

一、ExceptionRuntimeException的区别

  •   Exception是RuntimeException的父类,使用了 Exception 的类都必须对异常进行处理(try / throw / throws)
  •        RuntimeException 可以由选择性的对异常进行处理(可以不处理)

二、常见的 RuntimeException(即RuntimeException的子类)

  • ClassCastException
  • FileSystemNotFoundException
  • IndexOutOfBoundsException
  • NullPointerException

猜你喜欢

转载自www.cnblogs.com/linhuanjie/p/9499232.html