#Is a Lambda as class method body/implementation possible in Java?
13 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @wintry remnant! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
no, lambdas are for implementing entire classes
they're for functional interfaces, interfaces with 1 abstract method
A lambda is a variable that contains code
It has the type of a interface
With only one method
Interface lambda = (args) -> {//code};
To run the lambda you have to call its Interfaces method
So let's say its run
Then you do lambda.run();
So no you can not use it for the method body