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