大家平时用Java8吗?用了哪些新的特性吗?
迷茫
迷茫 2017-04-18 09:55:21
0
3
450

我看到有报告说现在Java 8用的比较多,比JDK 7要多。大家平时用Java 8吗?
是像Java 7一样的用?还是用了哪些新的特性吗?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(3)
伊谢尔伦

Reference:
http://www.importnew.com/1190...
http://www.importnew.com/1036...

The following are the new features of Java 8 that I commonly use (sorted by frequency of use)
1. lamda expressions;
2. Streams;
3. Method references;
4. Default and static methods of interfaces;

Above, 1 and 2 are artifacts. I don’t want to explain them. However, it will feel a bit awkward at first because you are not used to them. Later, when you get used to them, writing code will feel like flying. (However, if you use it improperly, you can still write a shit (this is a human problem, anyone Language is inevitable), and in some scenarios the readability may not be better than traditional writing).
If you are proficient in using 3, some things that could only be achieved using reflection in the past can also be achieved through method references. It is recommended to become familiar with itFunction, Consumer, Predicate, Supplier.
4 is considered to enhance the interface, and it is not used very much.

Others are less used, but it is worth mentioning Date/Time API,试用了一下,的确比旧版的API好用和方便,感觉跟Joda time很相似了。奈何新版API的对象跟原有的Date、Time对象之间的转换却十分麻烦,加上公司一早就使用上了Joda Time,所以也就没怎么用新版的Date/Time API.

Ty80

The company uses 1.7, and when I play by myself, I use 1.8

黄舟

If it weren’t for Java 8, I would be too lazy to use Java.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!