JDK8 Lambda

之前看过JAVA 8的书,但由于时间长,平时没用所以忘的差不多了,大概记得格式。

常用代码

1.获得对象集合的某个属性倒序(最新)的一个对象

Optional<AppLog> appPLog = appLogList.stream().sorted(Comparator.comparing(AppLog::getCreationTime).reversed()).findFirst();

2.过滤条件的对象集合

List<User> filterList = list.stream().filter(user -> Integer.valueOf(user.getAge()) > 60).collect(Collectors.toList());

猜你喜欢

转载自www.cnblogs.com/julian-chang/p/11896996.html