O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting ready

Interface, in this case, is a reference type that defines the signatures of the methods one can expect to see in the class that implements the interface. It is the public face of the functionality accessible to a client and is thus often called an Application Program Interface (API). It supports polymorphism and composition and thus facilitates even more flexible and extensible design.

An interface is implicitly abstract, which means it cannot be instantiated (no object can be created based on an interface only). It is used to contain abstract methods (without body) only. Now, since Java 8, it is possible to add default and private methods to an interface--the capability we are going to discuss in the following recipes.

Each ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required