What is Inner class?

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.

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
Scroll to top