經(jīng)典梗 哈哈
public class Funny { public static void main(String[] args) { Coder me = new Coder("my name"); getGirl(me); } private static GirlFriend getGirl(Object boy) { return new GirlFriend(boy); } private static class Coder { Coder(String name) { } } private static class GirlFriend { GirlFriend(Object boy) { if (boy instanceof Coder) { throw new GirlNotFoundException("Not possible for you XD"); } else { System.out.println("Found"); } } } private static class GirlNotFoundException extends RuntimeException { GirlNotFoundException(String msg) { super(msg); } } }
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/66371.html
閱讀 1686·2021-11-19 09:40
閱讀 2939·2021-09-24 10:27
閱讀 3227·2021-09-02 15:15
閱讀 1888·2019-08-30 15:54
閱讀 1213·2019-08-30 15:54
閱讀 1377·2019-08-30 13:12
閱讀 642·2019-08-28 18:05
閱讀 2808·2019-08-27 10:53