jQuery in Action, 3rd edition
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

About interface

Pratik Thakare

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

Joined: Oct 02, 2003
Posts: 11884

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

Joined: Feb 26, 2001
Posts: 6341

Maybe you're thinking about an anonymous class:

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

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