We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
By defining the lambda, you are defining behaviour but not executing it at that point, and you are returning this to the PerformOperation Functional interface return type.
Then whoever uses this, ie who called odd(), will pass this lambda (retrieved via the PerformOperation reference returned from odd()) to a method that takes a PerformOperation Functional interface as a parameter.
It is in THIS called method that the lamda will be executed, and therefore the int parameter will be supplied.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Lambda Expressions
You are viewing a single comment's thread. Return to all comments →
By defining the lambda, you are defining behaviour but not executing it at that point, and you are returning this to the PerformOperation Functional interface return type. Then whoever uses this, ie who called odd(), will pass this lambda (retrieved via the PerformOperation reference returned from odd()) to a method that takes a PerformOperation Functional interface as a parameter. It is in THIS called method that the lamda will be executed, and therefore the int parameter will be supplied.