简体   繁体   English

Lambda表达式中的方法引用的方法引用

[英]Method reference of a method reference in a Lambda expression

I am new in Java 8, and I have this expression: 我是Java 8的新手,具有以下表达式:

 .map(mc -> mc.getName().getDefaultName())

and I would like to know if it could be replaced for something like: 我想知道是否可以将其替换为:

.map(TeleBadalonaCampaignType::getName::getDefaultName)

nope, not really - the language has no such construct; 不,不是真的-语言没有这种结构; unless you map it twice: 除非您将其映射两次:

.map(TeleBadalonaCampaignType::getName)
.map(WhateverObject::getDefaultName)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM