经典梗 哈哈
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); } } }
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/66371.html
阅读 1653·2021-11-19 09:40
阅读 2908·2021-09-24 10:27
阅读 3201·2021-09-02 15:15
阅读 1857·2019-08-30 15:54
阅读 1183·2019-08-30 15:54
阅读 1351·2019-08-30 13:12
阅读 606·2019-08-28 18:05
阅读 2774·2019-08-27 10:53