CHAPTER 17

image

Interface

An interface is a type that decouples “interface” from implementation. It specifies a contract between its implementors and objects that call its methods (and access its constants). They are defined with the interface keyword followed by a name and a code block. Their naming convention is the same as for classes, which is to have each word initially capitalized. When an interface is not nested inside another type, its access level can be either package-private or public, just as any other top-level member.

interface MyInterface {}

Interface members

The code block for an interface can first of all contain signatures for instance ...

Get Java Quick Syntax Reference 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.