Java Anonymous Inner Class is an Inner class (non-static nested class) that does not have any name. It is used in java to override the methods of interface and classes. Unlike other classes, it does not have any constructor (as the name of a constructor and the name of the class must be the same, but the anonymous inner class doesn’t have a name). It can be created either with an interface or with a class.
The anonymous inner class can extend only one class or can implement only one interface, unlike other classes that can extend a class and implement several interfaces simultaneously. There will be only one object created for an anonymous inner class. The expression for an anonymous inner class consists of:
The anonymous inner class can access the members of the enclosing class. It can also access the local variables in the enclosing block provided that they are declared as final.
#java #java anonymous