aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interface Collection, List, Set  and redundant declaration of many methods 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 "Interface Collection, List, Set  and redundant declaration of many methods" Watch "Interface Collection, List, Set  and redundant declaration of many methods" New topic
Author

Interface Collection, List, Set and redundant declaration of many methods

Aruna Agrawal
Ranch Hand

Joined: Jan 27, 2005
Posts: 66
interface List and interface Set both extends from interface Collection.

So when interace Collection declare
boolean containsAll(Collection c);

then why is same declaration made again in interface List and interface Set in the source code of jdk 1.4.2. I feel that containsAll(Collection c) declaration in List and Set are redundant

But is there something i am missing? definitely.. SUN cannot be so fool to do such things in there soource code of jdk 1.4.2

please help
Aruna
Animesh Shrivastava
Ranch Hand

Joined: Jul 19, 2004
Posts: 298

I feel that containsAll(Collection c) declaration in List and Set are redundant

No i dont think so we should call it to be redundant, its kinda Object Oriented Design what they have followed. List and Set have different implementation for containsAll(Collection c) method. So, they have made it quite meaningful by putting the same method in the two different interfaces.
Adam Czysciak
Ranch Hand

Joined: Feb 25, 2005
Posts: 90
    
    5
List and Set have different implementation for containsAll(Collection c) method. So, they have made it quite meaningful by putting the same method in the two different interfaces.


In fact, neither List nor Set has implementation for containsAll method, since these are interfaces


Adam
SCJA, SCJP 5.0, SCWCD 1.4, SCBCD 5, SCEA 5
Animesh Shrivastava
Ranch Hand

Joined: Jul 19, 2004
Posts: 298
I mean List and Set uses the containsAll method in their own defined ways,
the implementation is defined in the classes which implement these interfaces.
Aruna Agrawal
Ranch Hand

Joined: Jan 27, 2005
Posts: 66
Originally posted by Animesh Shrivastava:

its kinda Object Oriented Design what they have followed. List and Set have different implementation for containsAll(Collection c) method. So, they have made it quite meaningful by putting the same method in the two different interfaces.


thanks for the reply. Could u specify any links which suggest such kind of Object Oriented Design If it was for just 1 method then i understand but they have done it for many methods.

Thanks for reading
Aruna
 
 
subject: Interface Collection, List, Set and redundant declaration of many methods