Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Method reference of a method reference in a Lambda expression

I am new in Java 8, and I have this expression:

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

and I would like to know if it could be replaced for something like:

.map(TeleBadalonaCampaignType::getName::getDefaultName)
like image 385
Sandro Rey Avatar asked Jul 09 '19 08:07

Sandro Rey


Video Answer


1 Answers

nope, not really - the language has no such construct; unless you map it twice:

.map(TeleBadalonaCampaignType::getName)
.map(WhateverObject::getDefaultName)
like image 79
Eugene Avatar answered Oct 03 '22 15:10

Eugene