java自定义抛出异常
package test;/** * 异常中定义抛出异常 * @author Administrator * */public class ExceptionThrows { static void exceptionThrow(Boolean a) throws Exception { if (a == false) { //创建异常对象e Exception e = new Exception("抛出异常!"); throw e; //抛出异常 } } public static void main(String[] args) { try { boolean isFalse = false; exceptionThrow(isFalse); } catch (Exception e) { System.out.println(e.getMessage()); } }}