+1

Can you create an anonymous lambda expression in java?

so normally to do a lambda we would go: interface func =()->expression; and then call like func.method(); but is there any way to have the lambda expression created and executed in the same statement?

8/3/2018 11:32:11 AM

Robert Atkins

5 Answers

New Answer

+2

Guess something like this: https://code.sololearn.com/cFHEXFiZU909/?ref=app

+1

Ya you could create a method that receives a lambda for that interface and just calls the method!

+1

Chriptus13 so to do that i could just have the method accept the interface object and supply the lambda expression directly as an argument? or would i have to create a variable assigned that operation and pass the variable? because im more familiar with the latter and the former would probably best fit my question.

+1

Chriptus13 so the T represents an object pertaining to any data type? thats pretty neat! thanks!

0

Robert Atkins ya basicly xD