Inner Classes

Beginning with JDK 1.1, Java has supported the concept of nested, or inner, class declarations. Inner classes aren't found in most other programming languages, so its usefulness might not be clear to you at first. This section describes why inner classes exist and what purposes they serve.

Inner Classes Defined

Innerclasses are classes that are declared within the body of another class. In fact, you can even declare a class within the body of a method. You might wonder why you would ever want to declare one class inside another. You are never required to use inner classes when you develop in Java, but in certain situations they provide you with the ability to organize your code in a more understandable fashion, and, occasionally, ...

Get Special Edition Using Java 2 Standard 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.