finally{}代码块

package Exception;
/*
 * finally{}代码块
 * 
 * finally{]代码块是必须要被执行的,不管异常是否处理成功,该代码块里面的代码体都会被执行,
 */
public class FinallyException {
	public static void main(String[] args) {
		try{
			div(4, 0);
		}catch(ArithmeticException ae){
			System.out.println("出现了算术异常!!!");
		}finally{	//finally代码块是必须处理的
			System.out.println("异常处理完毕了!!!");
		}
	}
	public static int div(int a, int b)throws ArithmeticException{
		return a / b;
	}
}

  

posted on 2013-07-27 20:01  樱花满天  阅读(181)  评论(0)    收藏  举报

导航