Let’s begin by defining what a nested class is! A nested class is a class that can be found within another class. The process of a class being enclosed in another is known as encapsulation. Nested classes allow programmers to rationally organize and group classes that may be closely related in a Java program.

There are two main types of nested classes: non-static (also known as inner) nested classes, and static nested classes. The type of nested class determines whether it has access to other elements (static and non-static) within its encapsulating class. We will delve deeper into this topic in the coming exercises.

One significant benefit of implementing nested classes is that they provide an extra level of security by giving programmers the power to control the amount of access one class may have to another class and its methods.

For the rest of this lesson, we will be reviewing the different types of nested classes and how they can be implemented in a program. We will also learn about shadowing in relation to nested classes.


Take a look at the image associated with the exercise. It provides a breakdown of the types of classes that exist within Java.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?