Card 09/ 09

RecapDifficulty: Advanced1 min

One Abstract Method, Several Spellings

Five things this topic established, and where each one was.

What the topic established, and which card it was on
The thingWhere
A lambda is an object implementing an interface, chosen by where it is passedPassing Behaviour to a Method as an Argument
A functional interface has exactly one abstract methodWhat Makes an Interface Functional
Function, Predicate, Consumer and Supplier cover almost everythingFour Shapes on Two Axes
A method reference replaces a lambda that only passes its parameters throughMethod References
Captured locals must never be assigned to, because the lambda holds a copyWhy Your Lambda Cannot Change That Variable

A lambda has no type of its own. Everything about it — the parameter types, the return type, what it is allowed to touch — comes from the parameter it was handed to, and reading that parameter is how you read the lambda.