aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Anonymous Inner Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Anonymous Inner Class" Watch "Anonymous Inner Class" New topic
Author

Anonymous Inner Class

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi!
Is de same Anonymous Inner Class and Inner Class??
Thanks.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Jordi,
No way!
An anonymous class has no name.
An example:

An inner class can be any class defined inside another class. An example:

Regards,
Manfred.
kavita desai
Greenhorn

Joined: Jul 09, 2001
Posts: 16
Hi Jordi,
you can have various inner classes. Anonymous Inner class is one of them.
1. member inner class. which a class inside a class with a name but not same as the enclosing class
2. local inner class. class inside a method, has a name.
3. anonymous inner class. does not have a name, used widely in connection with event handling.
4. you can also have an interface inside a class.
hope that explains,
kavita desai
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Then, anonymous class is code without class??
kavita desai
Greenhorn

Joined: Jul 09, 2001
Posts: 16
it is rather class without a name. the comiler supplies all the necessary code. If we go by the example of anonymous class given by Manfred...in line 3, the anonymous class is created which extends Object and implements ActionListener. The compiler creates a class file for the anonymous class with the name... (supposing the name of the enclosing class is Outer) Outer$1.class.
please correct me if i am wrong,
kavita desai
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Anonymous Inner Class