---
title: "JAVA之Exception篇（1）——介绍"
author: "lynnwoo"
date: "2013-08-29T21:57:17Z"
tags: ["Java"]
categories: ["编程语言"]
slug: "java-exception-1"
draft: false
lastmod: "2013-08-29T22:42:56Z"
id: 1933545
url: "https://lynnwoo.iteye.com/blog/1933545"
---

我们都知道编码的2/8原则：80%代码都用来做异常处理，20%的代码完成80%的功能。由此可知熟练掌握异常是至关重要的。

 

JAVA的异常包括两种：Error和Exception。均为Throwable的子类。

 

1. Error：程序很困难或无法去处理的异常。比如StackOverflowError，一般把这类问题交个JVM。
2. Exception：分为两类被检查异常（Checked-Exception）和运行时异常（Runtime-Exception）。

被检查异常：指在编译时强制需要处理的异常。即方法声明中声明的异常。比如FileNotFoundException。

运行时异常：指在运行时程序可能出现的异常。程序运行正常时，不会出现运行时异常。需要在做程序设计的时候考虑到。