首页 > 编程语言 > 详细

Java Lambda表达式和方法引用

时间:2019-12-26 16:35:01      阅读:78      评论:0      收藏:0      [点我收藏+]

看了几个方法引用的例子: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)

Java Lambda表达式和方法引用

原文:https://www.cnblogs.com/xmddliu/p/12102358.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!