Inner Class Introduction

Inner Class Introduction

In this tutorial, we are going to discuss about Inner Class Introduction in java. We can declare a class inside another class such type of classes are called inner classes. This inner classes concept has introduced in 1.1 version as the part of event handling.

By observing the utilities and functionalities of inner class slowly the programmers are using this concept even in regular coding also. Without existing one type of object if there is no chance of existing another type of object then we should go for inner classes.

Inner Class Introduction

E.g 1

Without existing car object there is no chance of existing wheel object. Hence we have to declare wheel class inside car class.

class car {
   class wheel {
   
   }
}

E.g 2

A map is a collection of entry objects. With out existing Map object there is no chance of existing entry object. Hence we have to define entry interface inside map interface.

interface Map {
   interface Entity {

   }
}

Based on the purpose and position of inner class all the inner classes are divided into 4 categories.

  1. Normal/Regular inner classes
  2. Method local inner classes
  3. Anonymous inner classes
  4. Static nested classes

That’s all about the Inner Class Introduction in java. If you have any queries or feedback, please write us email at contact@waytoeasylearn.com. Enjoy learning, Enjoy Java.!!

Inner Class Introduction
Scroll to top