Java runnable object expected but passed in a method [duplicate]

Runnable is a functional interface, as such, it can be replaced by a lambda expression or a method reference.
This is what you got here – claim(Runnable action) can get any lambda or method reference to a method that meets the Runnable#run signature – getting zero parameters and return void, regardless if this method is called run or if the class implements the interface – if the signature fits – it can work as functional interface.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top