看了几个方法引用的例子:http://ifeve.com/java-8-features-tutorial/
不是很清楚几种方法引用写法与静态和实例、带参和无参方法的对应关系,下面表格来自于:https://dzone.com/articles/java-lambda-method-reference,帮助自己理解
Type |
Syntax |
Lambda |
Reference to a static method |
ClassName::staticMethodName |
(args) -> ClassName.staticMethodName(args) |
Reference to an instance method of an existing object |
object::instanceMethodName |
(args) -> object.instanceMethodName(args) |
Reference to an instance method of an arbitrary object of a particular type |
ClassName::instanceMethodName |
(arg0,rest) -> arg0.instanceMethodName(rest) Note: argo is of type ClassName |
Reference to a constructor |
ClassName::new |
(args) -> new ClassName(args) |
原文:https://www.cnblogs.com/xmddliu/p/12102358.html