O'Reilly logo

Java: A Beginner’s Tutorial, 4th Edition (Updated for Java SE 8) by Budi Kurniawan

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

Chapter 18

Nested and Inner Classes

Nested and inner classes are often considered too confusing for beginners. However, they have some merits that make them a proper discussion topic in this book. To name a few, you can hide an implementation completely using a nested class and it provides a shorter way of writing an event-listener.

This chapter starts by defining what nested classes and inner classes are and continues by explaining types of nested classes.

An Overview of Nested Classes

Let’s start by learning the correct definitions of nested and inner classes. A nested class is a class declared within the body of another class or interface. There are two types of nested classes: static and non-static. Non-static nested classes are called inner ...

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