Closures (aka Lambdas)
Reading
- Read CH 6.3: Lambda Expressions from “Core Java Volume 1 — Fundamentals” by Cay S. Horstmann. This reading mentions some concepts we have not covered in class (such as ActionListener, Comparator), but you should be able to understand the core points.
Important concepts
- Lambda expressions (aka closures)
- Variable capture
- Java closure syntax variants
- Comparators
Things to consider (exercises for yourself, not to turn in)
- What is the difference between a lambda expression and a method?
- What is a functional interface? How is it connected to lambda expressions?
- How could you change the code at the bottom of page 323 to make it legal, but still use the value of the variable i in the lambda?
Your response
What was particularly interesting, confusing, or exciting to you in this reading?