Log in from a computer to take this course

You'll need to log in from a computer to start Learn Intermediate Java. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
Learn

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 a class in a program is defined as determines whether the nested class has access to other elements (static and non-static) within their encapsulated class. We will delve deeper into this topic in the coming exercises.

One major 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.

Instructions

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?