-
受检异常(checked exception):
在编译时需要检查的异常,需要用try-catch或throws处理。 -
非受检异常(unchecked exception):
不需要在编译时处理的异常。在java中派生于Error和RuntimeException的异常都是unchecked exception。 -
受检异常举例:
class A{ public static void main(String[]args){ try(Scanner sc=new Scanner(System.in)){ int a=sc.nextShort(); }catch (Exception e){ e.printStackTrace(); } } } -
非受检异常举例:
class A{ public static void main(String[]args){ int []a; System.out.println(a[0]); } }



