In Java, you can create a class within another class and store them together such classes are nested classes. The containing class is the top-level class. There are four types of nested classes:
Static member classes: A static member class has access to all static methods of the top-level class.
Nonstatic member classes: also known as inner classes: This type of class requires an instance; it has access to all data and methods of the top-level class.
Local classes: These are local to a block of code.
Anonymous classes: These are local classes that have no identifier.