总结:抛出异常 

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");
		}
	}
}

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2022-12-23
  • 2021-08-04
相关资源
相似解决方案