标签:super pre col throw new bounds this exce throws
自定义异常就为了一个名字而已
public void setAge(int age) throws AgeOutOfBoundsException { if (age > 0 && age <120) { this.age = age; } else { throw new AgeOutOfBoundsException("年龄非法"); } } } class AgeOutOfBoundsException extends Exception{ public AgeOutOfBoundsException(String dec) { super(dec); } }
标签:super pre col throw new bounds this exce throws
原文地址:https://www.cnblogs.com/yaobiluo/p/11306492.html