A local class that is defined without a name is known as Anonymous class.
Anonymous classes are instantiated only once. We create a new class every time
while executing a given anonymous class definition. Anonymous classes can be
extended and can also implement an interface. In case of anonymous class, define
a class right in the middle of an expression which allows us by an inner class.
The syntax of anonymous classes is as under :
| new class_name ( [ argument-list ] ) { ....... class-body ....... ....... } |
Anonymous classes can not be declared as static because they don't have a normal class declaration where it's possible to use static. They can't be define with modifiers like public, private, protected or static.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Anonymous Classes
Post your Comment