• 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 Framework

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I want to make my knowledge of Collection Framework better. Can anybody suggest any links for the same which can give me each and every information about the collections, regarding which collections to use , when to use the particular type of collection, the performance issue whicle using the particular type of collection etc.

Thanks in advance.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you run through the Sun Collections Tutorial? I made a little cheat sheet that compares a few of the most common implementations.
 
piyush kumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have read the collection tutorial , i want some thing related to performance tuning with collection can anybody help me with that.
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Collections Framework has been tuned for performance.

You need to read things like the Arrays.sort() method, Collections.sort(), the documentation for ArrayList ArrayDeque and LinkedList, or the RandomAccess interface in the API website. Look for where it uses linear time, constant time, quadratic time, etc.
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by piyush kumar:
Hi All,

I want to make my knowledge of Collection Framework better. Can anybody suggest any links for the same which can give me each and every information about the collections, regarding which collections to use , when to use the particular type of collection, the performance issue whicle using the particular type of collection etc.

Thanks in advance.



Actually, you have asked what is a very involved subject. In short read all of the docs or unpacked sources in :
  • java.util.Vector;
  • java.util.List;
  • java.util.ArrayList;
  • java.util.Map;
  • java.util.TreeMap;
  • java.util.TreeSet;
  • java.util.Stack;
  • java.util.SortedSet;
  • java.util.SortedMap;
  • java.util.Set;
  • java.util.RandomAccess;
  • java.util.Queue;
  • java.util.ListIterator;
  • java.util.LinkedList;
  • java.util.LinkedHashSet;
  • java.util.Iterator;
  • I have more of these open in my editor, but for now just google the above terms or read the documentation or Learning Trails at the Sun site that come up in a google for the above terminology, in paticular paying attention for keywords Campbell R. gives in his reply.

    Look first for how much faster a Collection can be searched for a paticular item if sorting has been done, and consider the cost of sorting compared to how often a Collection must be searched for a paticular item.
     
    Greenhorn
    Posts: 26
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    It would be better, if you come up with a scenario where you use a collection class and want to improve perfomance or looking for best practice. As pointed out by other ranchers, the best place to start is the sun tutorial. But if you have more specific question, feel free post your question.

    If you are looking for a key-value mechanisms, Map is the way to go. Note: there are many ways you can use a Map

    If you are looking for some kind of listing, use a List.

    Once you start using these Collection interfaces and classes, you will realize the power of them.


    Sincerly,
    Your friends at www.javaadvice.com
    www.javaadvice.com - The one stop resource for all your Java questions and answers.
    [ January 17, 2008: Message edited by: Lukasz Bajzel ]
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic