Anonymous Classes

A local class that is defined without a name is known as Anonymous class.

Anonymous Classes

     

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.

Advertisements

 

We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.

Share on Google+Share on Google+

Anonymous Classes

Posted on: June 16, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Anonymous Classes  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
hariprakash
August 11, 2013
about anonymous classes

basically for what purpose we are using anonymous class?

Ads

 

Ads