阅读背景:

有种异常叫你没有女朋友

来源:互联网 
public class NotGirlFriendException extends Exception { public NotGirlFriendException() { } public NotGirlFriendException(String message) { super(message); } } public class GirlFriend { String name; int age; public GirlFriend(String name, int age) throws NotGirlFriendException { this(); this.name = name; this.age = age; } public GirlFriend() throws NotGirlFriendException { throw new NotGirlFriendException("you are not girlfriend"); } } public class Test { public static void main(String[] args) { try { GirlFriend girlFriend=new GirlFriend(); }catch (NotGirlFriendException e){ System.out.println(e.getMessage()); } } } public class NotGirlFriendException extends Excep



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: