File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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: 11923

You can create an object/instance of a class that IMPLEMENTS the 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: 6521

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:
subject: About interface
It's not a secret anymore!