• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collection Framework

 
piyush kumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • 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.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • 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.
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • 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.
     
    Lukasz Bajzel
    Greenhorn
    Posts: 26
    • Mark post as helpful
    • send pies
    • 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 ]
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic