将保持插入顺序且不重复的集合 [英] Collection that will maintain insertion order and no duplicates

查看:173
本文介绍了将保持插入顺序且不重复的集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In Java collection which collection will doesn't allow duplicates and which also preserve insertion order of data?

推荐答案

LinkedHashSet

根据文档


此实现与HashSet的不同之处在于它维护一个
双向链接列表,其中包含所有条目。这个链接的
列表定义了迭代排序,即
元素插入集合的顺序(插入顺序)

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)

这篇关于将保持插入顺序且不重复的集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆