File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes object of an interface? Hows possible Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "object of an interface? Hows possible" Watch "object of an interface? Hows possible" New topic
Author

object of an interface? Hows possible

Rahul Shilpakar
Ranch Hand

Joined: Aug 29, 2006
Posts: 132
Hi,



The above code is compilable. I wonder how can we make object of Interface Runnable.
What is this concept? :evil:


Perform for today. Adapt for tomorrow.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

Search for the term "anonymous class".


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
actually this is not an object of an interface however in a piece of code like this one you are extending/implementing the specified class/interface and then you override the needed methods. this method is named anonymos classes. and if you ever written swing code all your listeners are generally created in this way.


Omar Al Kababji - Electrical & Computer Engineer
[SCJP - 90% - Story] [SCWCD - 94% - Story] [SCBCD - 80% - Story] | My Blog
Stephen Davies
Ranch Hand

Joined: Jul 23, 2008
Posts: 352
Rob Prime wrote:Search for the term "anonymous class".


DOH! Thanks Rob, I have been wondering about this myself for a while, makes perfect sense now!
ops:

be a well encapsulated person, don't expose your privates, unless you public void getWife()!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: object of an interface? Hows possible