LinkedHashSet的特点: 可以保证怎么存就怎么取

package online.msym.set;
import java.util.LinkedHashSet;
public class Demo2_LinkedHashSet {
    /**
     * @param args
     * LinkedHashSet
     * 底层是链表实现的,是set集合中唯一一个能保证怎么存就怎么取的集合对象
     * 因为是HashSet的子类,所以也是保证元素唯一的,与HashSet的原理一样
     */
    public static void main(String[] args) {
        LinkedHashSet<String> lhs = new LinkedHashSet<>();
        lhs.add("a");
        lhs.add("a");
        lhs.add("a");
        lhs.add("a");
        lhs.add("b");
        lhs.add("c");
        lhs.add("d");
        
        System.out.println(lhs);
    }
}

LinkedHashSet的概述和使用

【点击此处回到主页】

相关文章:

  • 2022-02-12
  • 2022-02-08
  • 2021-12-10
  • 2022-12-23
  • 2022-01-07
  • 2022-01-06
  • 2021-04-05
  • 2021-11-14
猜你喜欢
  • 2022-03-09
  • 2020-03-02
  • 2022-12-23
  • 2021-06-18
  • 2021-11-15
  • 2021-11-12
  • 2021-06-10
相关资源
相似解决方案