• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 90
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic