aspose file tools
The moose likes Beginning Java and the fly likes How come the instantiation of interface workes in my code Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "How come the instantiation of interface workes in my code" Watch "How come the instantiation of interface workes in my code" New topic
Author

How come the instantiation of interface workes in my code

Rahul Shivsharan
Ranch Hand

Joined: Jun 17, 2009
Posts: 83


can anybody tell me wether we have instantiated interface or what ? i'm not able to understand the above code and how it works
Ulrika Tingle
Ranch Hand

Joined: Nov 24, 2009
Posts: 92
Rahul Shivsharan wrote:
can anybody tell me wether we have instantiated interface or what ? i'm not able to understand the above code and how it works


You've instantiated an anonymous class.

Anonymous means the class has no name.

The anonymous class is defined on the fly in code, so you can do new on it.
Manu Ullas
Greenhorn

Joined: Nov 25, 2009
Posts: 9
Rahul Shivsharan wrote:
can anybody tell me wether we have instantiated interface or what ? i'm not able to understand the above code and how it works


Ulrika Tingle is right. Ex01_24_09 is an anonymous-inner class that implements the Ex01_24_09 interface implicitly. It is anonymous because it doesn't have any name that you can use to refer to it later. And inner because it is defined as part of a statement in a method.

Also ex01 is an object of the anonymous class Ex01_24_09.

This should be able to explain anonymous and inner classes in detail.


It's hard to be objective and witty at the same time, unless you sacrifice rationality.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How come the instantiation of interface workes in my code
 
Similar Threads
Serializayion problem please help
Multiple inheritance in remote interfaces for EJB 3.0 session beans on Weblogic 10.3
implementing two interfaces with the same method name!
Static Methods in an Interface
Don't code like this at home