How Lambdas See the Variables Around Them¶
โ Java 17
A variable can show up in three places around a lambda: in its parameter list (what it receives), inside its body (what it creates) and outside it (what it borrows). Each place has its own rules, and the compiler enforces every one.
In this series¶
| # | Page | Reading time |
|---|---|---|
| 1 | Declaring lambda parameters | 3 min |
| 2 | Variables inside a lambda block | 3 min |
| 3 | Borrowing variables: the effectively final rule | 3 min |
| 4 | Lab: turning a long lambda into a method reference | 3 min |
๐ OCP 1Z0-829 candidates: exam traps and practice questions (optional)
Prerequisites: The Ready-Made Lambda Toolkit.