JDK8到JDK17有哪些吸引人的新特性?
https://juejin.cn/post/7223195139236216887
比较大的区别:
1、模块化(有Maven存在,好像没有太大改用Java自身模块化的必要?)
2、垃圾回收期ZGC(很强,但是想用需要升级高版本)
3、语法糖
4、标准Java HTTP Client客户端
5、增强的空指针异常(这个我感觉非常有用)
对比(老):
Exception in thread "main" java.lang.NullPointerException
at Prog.main(Prog.java:5)
对比(新):
Exception in thread "main" java.lang.NullPointerException:
Cannot read field "c" because "a.b" is null
at Prog.main(Prog.java:5)
Exception in thread "main" java.lang.NullPointerException:
Cannot load from object array because "a[i][j]" is null
at Prog.main(Prog.java:5)