9.1. Inner Classes

Inner classes are an advanced topic. They are not totally intuitive. Nor are they regularly necessary if you're mostly writing Java for the Web. The primary use of inner classes is in GUI development. They are covered here in the interest of completeness and flexibility.

Inner classes are also sometimes called nested classes. Simply put, an inner class is a class that has its definition inside of another class. Inner classes have complete access to the code in the outer class definition, including its private fields and methods.

When you compile a source file containing a class with an inner class definition, two .class files are created.

Note

There is an interesting thing about compilation and organization that comes up when ...

Get Java™ for ColdFusion® Developers 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.