© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2024
J. FriesenLearn Java Fundamentalshttps://doi.org/10.1007/979-8-8688-0351-2_9

9. Static, Non-static, Local, and Anonymous Classes

Jeff Friesen1  
(1)
Dauphin, MB, Canada
 

The classes that I’ve presented to this point are known as top-level classes. They don’t belong to another class or structure. However, Java also lets you declare classes in other classes, blocks (groups of zero or more statements between { and } characters), and expression contexts.

Classes declared in other classes are known as nested classes. There are two kinds of nested classes: static classes and non-static classes. (Non-static classes are also known as inner classes).

Note

The Java Tutorials ...

Get Learn Java Fundamentals: A Primer for Java Development and Programming 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.