image

CHAPTER7

API Evolution with Default Methods

Default methods allow interfaces to define behavior. Why did we need this change, and what are its consequences? The short answer to the first question is: to support API evolution. The need for this has been felt for a long time, but became pressing with the requirement for stream support in collections. (The longer answer is that, once introduced, default methods have other uses as well, as we shall see.) The Java Collections Framework—like its extensions, for example Google Guava—is strongly interface-based: that is, the capabilities of a collection are (with some exceptions) defined by the Javadoc ...

Get Mastering Lambdas now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.