更新时间:2021-10-10 17:34:57
.filter(x->x!=null) == .filter(Objects::nonNull)
有趣的是你已经使用了方法参考(但没看到这一个):
It's interesting that you already use a method reference in(but failed to see this one):
max(Date::compareTo)
此外,您显然会返回日期
但是来自可选<日期>
,您应该收到警告(如果使用IDEA),直接在可选$ c $上调用
获取
是不安全的c>。
Also you are obviously returning a Date
but from an Optional<Date>
, you should get a warning (if using IDEA) that it's not safe to call get
directly on an Optional
.
你还可以用 max(Date :: compareTo)
> max(Comparator.naturalOrder())因为日期
已经可比较
。
And you could also replace that max(Date::compareTo)
with max(Comparator.naturalOrder())
since Date
is already Comparable
.