OCP EXAM OBJECTIVES COVERED IN THIS CHAPTER:
- Programming Abstractly Through Interfaces
- Declare and use List and ArrayList instances
- Understanding Lambda Expressions
When we covered the Java APIs in the previous chapter, we didn’t cover the ones that use lambda syntax. This chapter remedies that! You’ll learn what a lambda is used for, about common functional interfaces, how to write a lambda with variables, and the APIs on the exam that rely on lambdas.
Writing Simple Lambdas
Java is an object-oriented language at heart. You’ve seen plenty of objects by now. In Java 8, the language added the ability to write code using another style.
Functional programming is a way of writing code more declaratively. ...