Unlike nested top-level classes, inner classes are not directly part of a package and are not visible outside the class in which they are nested. This is an inner class declared within a block, typically within a method It is not a member of the enclosing class. Their visibility is only within the block of their declaration. In order for the class to be useful beyond the declaration block, it would need to implement a more publicly available interface. Because local classes are not members, the modifiers public, protected, private, and static are not usable.
Local classes can access only final varaibles or parameters.
Anonymous class A variation on a local class. The class is declared and instantiated within a single expression These classes are simply inner classes that are not given a specific name. When you don't even need a name because you really just want to pass a method that does something, then you can get away with creating an anonymous inner class. Typically, a class is not named when it is used only once. We are declaring an object of an anonymous class type that either implements the interface or extends the class.