Home

News: Which Java collection to use?

  1. Which Java collection to use? (10 messages)

    Introduction

    Java collections are one of the most commonly used data-structures by all Java professionals. But are you using the right collection class that would best suits your need. Most programmers usually end up useing Vectors, ArrayList, HashMap or Hashtable. There are many other collection classes available with the JDK that you can use instead of re-inventing some common logic that might suite your need.

    Factors that could help on deciding a Collection

    There are various factors that can be considered when selecting an appropriate collection for a particular problem. These factors are:

    1. Ordering - Some sort of ordering in the elements. For example, sorted order, insertion order or no specific ordering.
    2. Duplicates - May or may not want to allow duplicate elements in a collection.
    3. Thread Safe - Ensure the safety of the elements in a collections in case there are multiple threads accessing it.
    4. Key-Value pair - Store in key-value pairs.
    5. Blocking operations - Wait for the collection to become non-empty when retrieving an element.
    6. Random Access - Instant retrieval of an element.
    7. Upper Bounds - To limit the maximum number of elements a collection can hold.

    There are also other factors like priority, delay etc..

    Read full article and download the "Java Collection Matrix".

    Threaded Messages (10)

  2. disappointing content[ Go to top ]

    I thought the article will outline which collections to use; their comparison and best fit scenario based on the selection criteria mentioned by the author.

    The article just ends abruptly.. the collection matrix says "The following matrix will help in deciding which Java Collection Class would best fit your requirement." and there is no matrix in there.. is it a browser problem that I might be having or there is no matrix?

  3. The PDF file.[ Go to top ]

    I am extremely sorry for the inconvinience you are facing. It is definitley a browser issue. Click here to see the Java Collection Matrix

  4. Updated the original article.[ Go to top ]

    Dear Ayusman,

    Thanks for pointing out the issue in the article. I have added an alternate link below the matrix. It was supposed to show the matrix within the same page.

  5. This was how the JavaCollection Matrix was supposed to look like.

    http://prntscr.com/d68jw

  6.  

    Enterprise Java Web Application Development Platform

    JDesigner® Platform for building a Web application framework, common service, web template, development tools, and for the server to operate an all-in-one productivity by providing innovative open source Java/J2EE web application development platform.

    Thank you.

     

  7.  

    Enterprise Java Web Application Development Platform

    JDesigner® Platform for building a Web application framework, common service, web template, development tools, and for the server to operate an all-in-one productivity by providing innovative open source Java/J2EE web application development platform.

    Thank you.

     

     

    Let me learn some Korean / Japanese first then I'll look at your project which seems to use Korean / Japanese in the documentation.

  8. Have you ever used javolution?[ Go to top ]

    Its last version was in April 2010. Does anybody still use it and why?

  9. Best performance with removeAll?[ Go to top ]

    Say you have collection with 20 million numbers and other with 19 million. which one of the libraries/classes can handle this efficiently with a single removeAll - methodcall?

  10. Incomplete[ Go to top ]

    I'm missing the LinkedHashMap and LinkedHashSet.

  11. Will add these to the list.[ Go to top ]

    John,

    Thanks for pointing this out. I will surely add LinkedHashSet and LinkedHashMap to the Matrix.