开发者

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

开发者 https://www.devze.com 2023-01-27 17:22 出处:网络
This question already has answers here: Which Java Collection should I use? (6 answers) Closed 8 years ago.
This question already has answers here: Which Java Collection should I use? (6 answers) Closed 8 years ago.

As we all know with Java comes the Collections API that provide us with numerous data structures that we can use. 开发者_C百科

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.


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.

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


This should give you a pretty good breakdown...


There are enough answers provided already but I would like to augment those with few "application" areas where certain data structures are being used to solve problems

List of most of the data structures can be found on wikipedia here. Most of them have a "Applications" section that describes the problem domain it is solving


Just reading when to use what collection will only help you if you run across the exact same situation in your code. If you don't understand the roots of why a given data structure is good for a problem, you won't be able to apply this to your own code. This is why computer science is still important in programming...

So my roundabout answer, is take data structure classes or read data structure books, and understand how they work.

0

精彩评论

暂无评论...
验证码 换一张
取 消