---
title: "unchecked exception及checked exception的区别"
author: "Jseeker"
date: "2010-12-14T10:43:07Z"
tags: []
categories: ["编程语言"]
slug: "unchecked-exception-checked-exception"
draft: false
lastmod: "2010-12-14T10:43:07Z"
id: 841544
url: "https://jseeker.iteye.com/blog/841544"
---

# unchecked exception及checked exception的区别

**1. checked exception**

a. 都是Exception的子类，若子类可能抛出X异常，则父类也必须throws X异常，效率低，耦合度高。

b. 需要强制catch，否则编译器直接报错。

 

**2. unchecked exception**

a. 都是RuntimeException的子类。

b. 非必须catch，是无法预料的。比如，list..size()，若list=null， 则会抛出NullPointerException，该异常是一个RuntimeException， 也就是unchecked exception。