小计

2020-11-16  本文已影响0人  一叶知秋_zgx
public static void main(String[] args) {
        Student student = new Student();
        Aaa aaa = new Aaa();
        Bbb bbb = new Bbb();
        bbb.setName("恭喜你");
        aaa.setBbb(bbb);
        student.setAaa(aaa);
        Object end = Optional.ofNullable(student)
                .map((a) -> a.getAaa())
                .map((b) -> b.getBbb())
                .map((n) -> n.getName())
                .orElse(null);
        System.out.println(end);
    }

上一篇下一篇

猜你喜欢

热点阅读