7.2. Static Member Classes and Interfaces

Declaring and Using Static Member Classes and Interfaces

A static member class or a static member interface comprises the same declarations as those allowed in an ordinary top-level class or interface. A static member class must be declared as a static member of an enclosing class or interface. Nested interfaces are considered implicitly static, the keyword static can, therefore, be omitted. Since static member classes and interfaces are members of an enclosing class or interface, they can have any member accessibility.

Static member classes and interfaces can only be nested within other static member or top-level classes and interfaces.

In Example 7.2, the top-level class TopLevelClass at (1) contains ...

Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition 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.