java - 将保持插入顺序且没有重复的集合

标签 java collections

在 Java 集合中,哪个集合不允许重复,哪个还保留数据的插入顺序?

最佳答案

LinkedHashSet

根据 documentation

This implementation differs from HashSet in that it maintains a doubly-linked list running through all of its entries. This linked list defines the iteration ordering, which is the order in which elements were inserted into the set (insertion-order)

关于java - 将保持插入顺序且没有重复的集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16480529/

相关文章:

java - LinkedHashSet - 插入顺序和重复 - 保持最新的 "on top"

java - 如何在 Java 中将 int[] 转换为 List<Integer>?

java - 在 2 个 Activity 之间传递数据

java - 在 Rails 和 Java 中使用时区

c# - 我什么时候可以在 native foreach 循环上使用 List<T>.ForEach?

scala:以功能方式从集合中累积一个var(即没有vars)

Excel VBA : Why "Sheets" collection is not a "Collection"?

java - 如何在java中获取Map中重复键的最新值?

java - 以编程方式将数据从 S3 或 Azure 加载到 MemSQL 的最佳方式是什么?

java - 如何停止 MediaPlayer 流然后重新启动它?安卓