(问完就删)为什么这里可以传入Item::getDescription
java吧
全部回复
仅看楼主
level 8
湫和海棠
楼主
2020年12月22日 10点12分
1
level 8
湫和海棠
楼主
按照的Comparator.comparing的定义
2020年12月22日 10点12分
2
level 8
湫和海棠
楼主
这里应该传入一个参数是? super T的参数,返回值是? extends U的函数,或者lambda表达式
2020年12月22日 10点12分
3
level 8
湫和海棠
楼主
可是 getDescription()是这样定义的啊
2020年12月22日 10点12分
4
生活要二才有爱
你可以想想description属性是从哪里来的,首先要拿到item吧。那么传参不就是item,返回值不就是item.description。 这不就是一个Funciton吗? 也可以看做是 (item) -> item.getDescription()
2020年12月22日 12点12分
湫和海棠
@生活要二才有爱
考虑下
2020年12月22日 13点12分
湫和海棠
@生活要二才有爱
悟了谢谢大佬
2020年12月22日 13点12分
level 11
这题好难啊😫
兄弟,兰八大方法函数也可以当参数
2020年12月22日 11点12分
5
湫和海棠
?
2020年12月22日 11点12分
level 11
这题好难啊😫
兄弟参考这个https://www.liaoxuefeng.com/wiki/1252599548343744/
13051580551
00449
2020年12月22日 11点12分
6
level 8
就是喜欢骚的😻
方法引用
2020年12月22日 11点12分
7
湫和海棠
这个我知道,但是Function<T,R>,不应该引用一个有参数的方法吗?getDescription方法没有参数,凭什么能够引用?
2020年12月22日 13点12分
level 7
LN840434235
lambda表达式中有一种方法引用的写法
2020年12月22日 11点12分
8
湫和海棠
这个我知道,但是Function<T,R>,不应该引用一个有参数的方法吗?getDescription方法没有参数,凭什么能够引用?
2020年12月22日 13点12分
我是洛秋啊🍒
@湫和海棠
Function<T, R> 返回的是Integer,参数就是本身类型
2020年12月23日 06点12分
我是洛秋啊🍒
返回String
2020年12月23日 06点12分
level 1
hai1234344
jdk 1.8特性之一
2020年12月22日 11点12分
9
level 10
直到某天我足够坚强
流式计算 jdk新特性 可以玩一玩
2020年12月22日 12点12分
10
level 8
湫和海棠
楼主
源码如下,可以正常跑
2020年12月22日 13点12分
11
level 7
Silvae💝
item -> item.getDescription()
2020年12月22日 13点12分
12
湫和海棠
悟了,谢谢大佬
2020年12月22日 13点12分
湫和海棠
@湫和海棠
这什么鸡儿语法?很误导人啊....
2020年12月22日 13点12分
level 8
湫和海棠
楼主
悟了,谢谢大家
2020年12月22日 13点12分
13
1