© Mikael Olsson 2022
M. OlssonJava 17 Quick Syntax Referencehttps://doi.org/10.1007/978-1-4842-7371-5_18

18. Interface

Mikael Olsson1  
(1)
Hammarland, Länsi-Suomi, Finland
 
The interface type is used to specify methods that classes using the interface must implement. These methods are created with the interface keyword followed by a name and a code block. Their naming convention is the same as for classes, with the first letter of each word capitalized.
interface MyInterface {}

When an interface isn’t nested inside another type, its access level can be either package-private or public, just like any other top-level member.

Interface Members

The code block for an interface can, first of all, contain signatures for instance methods. These methods don’t ...

Get Java 17 Quick Syntax Reference: A Pocket Guide to the Java SE Language, APIs, and Library 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.