O'Reilly logo

Java Quick Syntax Reference by Mikael Olsson

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

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 ...

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