my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes One Doubt of creating objects of interface.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "One Doubt of creating objects of interface.." Watch "One Doubt of creating objects of interface.." New topic
Author

One Doubt of creating objects of interface..

Bijendra S. Rajput
Ranch Hand

Joined: Sep 19, 2006
Posts: 41
Hi, all

There is one program in KS & BB on page 222.
They have one interface .......

interface Sporty (
void beSporty();
)

and in main class they are instanciating that interface....

Sporty[] SportyThings = new Sporty [3];
I think that...... we can not create a object of a interface ....

Could any body can tell me ?

Thanks,

Bijendra


Thanks <br /> <br />Regards,<br />------------------------------<br />Bijendra S. Rajput<br />SCJP 1.5<br />------------------------------
Petrus Pelser
Ranch Hand

Joined: Feb 20, 2006
Posts: 132
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: http://aspose.com/file-tools
 
subject: One Doubt of creating objects of interface..
 
Similar Threads
enum methods
Can i modify the interface sun providing
Interface and Composition realtion
Array of interface type -Where do we use it in real time applications?
What is the interface?