i 绝望

依然

Miss Lang

java代码throws异常

总结:抛出异常 

package com.ds;

//异常捕获
public class fdsg {
	private static void throwException() {
		try {

			String a = null;
			if (a == null) {
				throw new NullPointerException("s is null");
			}
		} catch (NullPointerException e) {
			System.out.println("方法throwException()中抛出一个NullException异常,");
			throw e;
		}
	}

	public static void main(String[] args) {
		try {

			throwException();
		} catch (NullPointerException e) {
			System.out.println("捕获方法throwException()中的异常NullPointerException");
		}
	}
}

  

posted on 2013-11-13 22:57  juewang  阅读(278)  评论(0编辑  收藏  举报

绝望依然

Miss Lang