This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Collection Framework Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Collection Framework" Watch "Collection Framework" New topic
Author

Collection Framework

piyush kumar
Greenhorn

Joined: Feb 01, 2007
Posts: 20
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

Joined: Jan 29, 2003
Posts: 8791
Have you run through the Sun Collections Tutorial? I made a little cheat sheet that compares a few of the most common implementations.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
piyush kumar
Greenhorn

Joined: Feb 01, 2007
Posts: 20
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

Joined: Oct 13, 2005
Posts: 37907
    
  22
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

Joined: Sep 17, 2006
Posts: 1282
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

    Joined: Dec 03, 2007
    Posts: 26
    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 ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Collection Framework
     
    Similar Threads
    Collection, Collections, Java Collections Framework
    Hash Table
    Collections and Generics
    What's the suitable Data structure
    Binary tree and Collections framework.