• 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

Collection Interface

 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could anyone proivde me an example of how to implement Collection Interface and how to use some of those methods like containsAll,addAll etc.
Thanks
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please see this link.
 
suresh kamsa
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on the above link but I am not able to figure it out how to write code which will make use of some of those methods. Do anyone have any examples ?
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What specifically are you trying to do? Are you sure you need to implement the interface, as opposed to just using it?
 
suresh kamsa
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wanted to implement collection interface and work with it.
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Suresh,
You don't implement the collection interface directly, you implement a subinterface like so:
Map m = new Hashmap();
or
List l = new LinkedList();
or
Set s = new HashSet();
Then, you can add Objects to the collection!
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What kind of collection do you want to implement that isn't already provided in standard Java?
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do not forget Thomas Paul's excellent article suite in the Javaranch Newsletter:
June 2002: Collections in Java Part 1 - The List Interface by Thomas Paul
July 2002: Collections in Java Part 2 - The Set Interface by Thomas Paul
August 2002: Storing Objects in Java Part 3 - The Map Interface by Thomas Paul
September 2002: Storing Objects in Java Part 4 - The Collections Class by Thomas Paul
[ September 16, 2002: Message edited by: Valentin Crettaz ]
reply
    Bookmark Topic Watch Topic
  • New Topic