+ 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?

3rd Aug 2018, 11:32 AM
StealthyTaco
StealthyTaco - avatar
5 Respuestas
4th Aug 2018, 1:26 PM
Chriptus13
Chriptus13 - avatar
+ 1
Ya you could create a method that receives a lambda for that interface and just calls the method!
4th Aug 2018, 2:21 AM
Chriptus13
Chriptus13 - avatar
+ 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.
4th Aug 2018, 8:10 AM
StealthyTaco
StealthyTaco - avatar
+ 1
Chriptus13 so the T represents an object pertaining to any data type? thats pretty neat! thanks!
4th Aug 2018, 3:38 PM
StealthyTaco
StealthyTaco - avatar
0
Robert Atkins ya basicly xD
5th Aug 2018, 3:24 AM
Chriptus13
Chriptus13 - avatar