且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在LinkedHashMap中的特定索引/位置添加元素?

更新时间:2023-12-06 17:32:34

您无法更改订单。此构造函数为 insert-order (默认情况下)或访问顺序

You can not change the order. It is insert-order (by default) or access-order with this constructor:


public LinkedHashMap(int initialCapacity,float loadFactor,boolean accessOrder)


  • 构造具有指定初始容量,负载因子和排序模式的空LinkedHashMap实例。

  • Constructs an empty LinkedHashMap instance with the specified initial capacity, load factor and ordering mode.

参数:
initialCapacity - 初始容量
loadFactor - 加载因子
accessOrder - 排序模式 - 对于访问顺序为true,对插入顺序为false

Parameters: initialCapacity - the initial capacity loadFactor - the load factor accessOrder - the ordering mode - true for access-order, false for insertion-order

抛出:
IllegalArgumentException - 如果初始容量为负值或负载因子为非正值

Throws: IllegalArgumentException - if the initial capacity is negative or the load factor is nonpositive

请参阅: LinkedHashMap