Monday, June 24, 2013

Don't know which map/collection to use?

This post will summarize about collection framework in a convenient way. This is continuation of the previous post about Collection Framework in Java

This diagram give you the basic understanding of when to use which collection.




This diagram give you the hierarchy of Collection framework with its ordering and sorting scenario.  








If you know anyone who has started learning java, why not help them out! Just share this post with them. Thanks for studying today!...

20 comments:

  1. A comprehensive diagram for deciding which Collection to use!

    ReplyDelete
  2. Nice - a picture paints a thousand words :-)

    ReplyDelete
  3. Thanks for the great pic, but I think LinkedLinked is also a good choice if you want duplicates

    ReplyDelete
    Replies
    1. I mean LInkedList not LinkedLinked

      Delete
    2. Actually, LinkedList is not the only choice for duplicates; there is also ArrayList, Vector, and Queue. That which you meant to say is that the List collection framework is the ideal choice for duplicates.

      Delete
  4. This was very nice summary. Thanks.
    Keep Posting !!!

    ReplyDelete
  5. duplicate? NO -->> searching? NO -->> Fast? NO -->> Sync? NO! then !!! ArrayList !!! NO DUPLICATE?

    ReplyDelete
  6. If synchronization is an issue, use the synchronized versions of the collection. See http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html Don't use Vector unless it is for some of its other features like returning an Enumeration of its elements.

    Overall, I think it is a nice post, but there are so many more collections to consider. This is a good start, and useful to many developers.

    ReplyDelete
    Replies
    1. Thanks John for your valuable comment, and yes, you are right there are synchronized versions of the collection which I'll slowly introduced in the same flow chart.

      Delete
  7. Great pic! Is there something wrong with LinkedList? I can reach it from [do u want duplicates = NO]

    ReplyDelete
  8. There is an error if you follow the no path for duplicates where it leads to LinkedList, which does allow duplicates. That path should lead go LinkedHashSet.

    ReplyDelete
  9. This was very impressive summary. Thank You so much.
    As soon as possible you'll need to update it with IdentityHashMap [http://docs.oracle.com/javase/1.5.0/docs/api/java/util/IdentityHashMap.html]

    ReplyDelete
    Replies
    1. Thanks, I'll surely add IdentityHashMap

      Delete
  10. Hello, I suggest to change stack to LIFO, it's not LILO.

    ReplyDelete
    Replies
    1. Thanks Alexis, It's a written mistake, I'll change it soon.

      Delete
  11. Here Linked HashSet and Linked HashMap are missed from Most talked about Collection

    ReplyDelete
  12. Hi, I am David from https://www.springmockexams.com and https://www.javamockexams.com.

    I really want to thank you for this post, I am going to share it on all my social media, if you do not mind!

    I am also really enthusiast to announce some very exciting news: to celebrate the imminent release of Spring 5 and Java 9 we launched our simulators SALE CAMPAIGN. We halved the price of our simulators at www.springmockexams.com and www.javamockexams.com for limited time only.

    If the audience is interested in accessing our price offer, they can take a look here http://www.cm.gy/sme and here http://www.clktr4ck.com/java

    Thanks and stay tuned for your featuring on our social medias!

    David

    ReplyDelete