Java优学网throw关键字教程:轻松掌握异常抛出技巧,告别调试烦恼

if(amount<0){thrownewIllegalArgumentException("转账金额不能为负数");}thrownewExceptionType("异常描述信息");//throw的使用publicvoidvalidateAge(intage){...