我应该使用哪个Java集合?

编程入门 行业动态 更新时间:2024-10-26 22:30:24
本文介绍了我应该使用哪个Java集合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在此问题中最简单的署名是链接到此问题或此答案。

其他资源

可能最有用的其他参考是或的下一页acle文档,其中描述了每个集合。

HashSet与TreeSet

关于何时使用 HashSet的详细讨论或 TreeSet 此处: 哈希与树集

ArrayList与LinkedList

详细讨论:何时在ArrayList上使用LinkedList?

In this question How can I efficiently select a Standard Library container in C++11? is a handy flow chart to use when choosing C++ collections.

I thought that this was a useful resource for people who are not sure which collection they should be using so I tried to find a similar flow chart for Java and was not able to do so.

What resources and "cheat sheets" are available to help people choose the right Collection to use when programming in Java? How do people know what List, Set and Map implementations they should use?

解决方案

Since I couldn't find a similar flowchart I decided to make one myself.

This flow chart does not try and cover things like synchronized access, thread safety etc or the legacy collections, but it does cover the 3 standard Sets, 3 standard Maps and 2 standard Lists.

This image was created for this answer and is licensed under a Creative Commons Attribution 4.0 International License. The simplest attribution is by linking to either this question or this answer.

Other resources

Probably the most useful other reference is the following page from the oracle documentation which describes each Collection.

HashSet vs TreeSet

There is a detailed discussion of when to use HashSet or TreeSet here: Hashset vs Treeset

ArrayList vs LinkedList

Detailed discussion: When to use LinkedList over ArrayList?

更多推荐

我应该使用哪个Java集合?

本文发布于:2023-11-09 05:19:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571488.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!