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 basic understanding of when to use which collection.
A comprehensive diagram for deciding which Collection to use!
ReplyDeleteNice - a picture paints a thousand words :-)
ReplyDeleteThanks for the great pic, but I think LinkedLinked is also a good choice if you want duplicates
ReplyDeleteI mean LInkedList not LinkedLinked
DeleteActually, 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.
DeleteThis was very nice summary. Thanks.
ReplyDeleteKeep Posting !!!
duplicate? NO -->> searching? NO -->> Fast? NO -->> Sync? NO! then !!! ArrayList !!! NO DUPLICATE?
ReplyDeleteIf 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.
ReplyDeleteOverall, 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.
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.
DeleteGreat pic! Is there something wrong with LinkedList? I can reach it from [do u want duplicates = NO]
ReplyDeleteYou can have duplicate in linkedlist.
Deleteexactly, that is why I wrote this comment...
DeleteThere 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.
ReplyDeleteThis was very impressive summary. Thank You so much.
ReplyDeleteAs 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]
Thanks, I'll surely add IdentityHashMap
DeleteHello, I suggest to change stack to LIFO, it's not LILO.
ReplyDeleteThanks Alexis, It's a written mistake, I'll change it soon.
Deletesure, please change it.
DeleteHere Linked HashSet and Linked HashMap are missed from Most talked about Collection
ReplyDelete