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 About interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "About interface " Watch "About interface " New topic
Author

About interface

Pratik Thakare
Greenhorn

Joined: Aug 29, 2012
Posts: 3
Hi I am just a beginner for java
I have 1 doubt
Q) I read that we can create a object of an interface . This is True but interface do not have constructors. So can any body please explane me What will be the flow . i mean how does this object is created ?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11302
    
  16

You can create an object/instance of a class that IMPLEMENTS the interface...so assuming the class Widget implements WorkerBee, you can do this:

WorkerBee myBee = new Widget();

so the object is really a Widget, but you can treat it like a WorkerBee.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4462
    
    6

Maybe you're thinking about an anonymous class:



Junilu - [How to Ask Questions] [How to Answer Questions]
Pratik Thakare
Greenhorn

Joined: Aug 29, 2012
Posts: 3
Thanks a Lot ....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About interface