O'Reilly logo

Java Garage by Eben Hewitt

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

Static Inner Class

Inner classes can be static, meaning that they have access only to the static member variables of the outer class. The reason is that they don't share much of a relationship with the outer class—they're tied to the name of the outer class, but not an instance of the outer class. A static nested class can be instantiated without an instance of the outer class. You can access it just like any static member variable. These are also known as top-level nested classes because they really boil down to a way to control namespace.

For example, in C#, you can define arbitrary namespaces that have no correspondence to actual directory structure (not so in Java), and you can nest namespaces within a class or a bit of code almost willy-nilly ...

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