Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Aruna Agrawal
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 90
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Animesh Shrivastava
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic