A Peek into the default Methods
In the design we explored in the previous section, we used the default methods. default methods aren’t intrinsically tied to lambda expressions or the functional style of programming. But many of the convenience methods in collections wouldn’t have been possible without them.
Interface evolution is the key motivation behind default methods. The API defined in the early ’90s was a good idea back then, but for the platform to stay relevant it needs to evolve. The default methods provide a nondisruptive path for that. Moving forward, when we design with interfaces, we’ll likely use default methods. Let’s examine their behavior and how they intermix with classes.
The Java compiler follows a few simple rules to resolve ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access