gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 20:32:21 26 4
gpt4 key购买 nike

在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com