Inner Classes In Java

komal dongare
Jun 28, 2021

--

Java inner class or nested class is a class which is declared inside the class or interface, It improves the encapsulations. So objects know about the other objects that they need to know. If you don’t want to access the any class without the accessing the outer class Inner classes works well in this scenario.

Two special cases of Inner Classes:

  1. Local classes
  2. Anonymous classes

Local Classes:

Output:

Anonymous Classes:

Here we do not have name of the class, which implements or extends the nested interface or class.

Passed the object through anonymous class.

--

--

komal dongare
komal dongare

Written by komal dongare

0 Followers

Problem Solver, Programmer, Blockchain developer, and a guitarist. New and innovative ideas are always welcomed.

No responses yet