Cheat Sheet for Selecting Map/List/Set in Java

I have prepared a cheat sheet that can help to select appropriate Map, Set or List implementation when required. Java API has many implementations of interfaces mentioned, and it is not always clear which implementation should be used in a particular scenario. The cheat sheet comes in the form of a flow chart, which makes it easy to follow and understand.

The idea was inspired by Sergiy Kovalchuk. Sergiy made a flow chart using the most commonly used collections. I tried to take it one step further and make it much more thorough.  Please do let me know if anything needs to be corrected. I hope this can help developers out there to choose the right collection for the right job.

Cheat sheet for selecting appropriate set/list/map in Java

Click on the image to load it in a new window

Inspired by Sergiy Kovalchuk

 

10 thoughts on “Cheat Sheet for Selecting Map/List/Set in Java

  1. Pingback: Qual a melhor implementação de Collection e Mapas para o meu programa? « Blog do Erich

  2. Pingback: Rendimiento de las APIs de collection de java | aninki.net

  3. Pingback: Cheat sheet sobre el uso de Collections en Java | CyberHades

    • Hi Neil,
      You are right. A pure Hashtable itself cannot be sorted, but the data within it can. In other words, it is possible to sort Hashtable keys. I guess I should have been more clearer in the diagram :)

  4. Should it be used as a ‘cache’ or store construction expensive objects? Yes / No
    Hmm, I don’t think yes/no are valid answers to this question ;-)
    Otherwise great diargram!!

    • Thomas thank you :) and yes – “yes/no” are not exactly valid here. But I was simply trying to keep the diagram consized, therefore I chose one of the main differences :)