Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Collections: which collection to use and when? [duplicate]

As we all know with Java comes the Collections API that provide us with numerous data structures that we can use.

I was wondering if there is some collection/tutorial/advice that could explain the situations and best Collection for the problem.

Example : LinkedHashMap is good for building LRU caches.

like image 559
daydreamer Avatar asked Nov 27 '10 04:11

daydreamer


2 Answers

I just came across this question but I recently posted a Q&A here What Java Collection should I use? that also answers this question.

Collections Flow Chart

like image 123
Tim B Avatar answered Sep 29 '22 21:09

Tim B


This should give you a pretty good breakdown...

like image 40
Aaron McIver Avatar answered Sep 29 '22 21:09

Aaron McIver