Inner Classes In Java
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:
- Local classes
- 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.