File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Programmer Certification (SCJP/OCPJP)
One Doubt of creating objects of interface..
Bijendra S. Rajput
Joined: Sep 19, 2006
Sep 19, 2006 23:42:00
There is one program in KS & BB on page 222.
They have one interface .......
interface Sporty (
and in main class they are instanciating that interface....
Sporty SportyThings = new Sporty ;
I think that...... we can not create a object of a interface ....
Could any body can tell me ?
Thanks <br /> <br />Regards,<br />------------------------------<br />Bijendra S. Rajput<br />SCJP 1.5<br />------------------------------
Joined: Feb 20, 2006
Sep 19, 2006 23:45:00
If you look closely you will notice that they are not instantiating the interface, but declaring an array of the interface type. Which means that you will be able to add objects to the array that implements the interface.
I agree. Here's the link:
subject: One Doubt of creating objects of interface..
Can i modify the interface sun providing
What is the interface?
Interface and Composition realtion
Array of interface type -Where do we use it in real time applications?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014