📜  Java.util.LinkedHashMap类

📅  最后修改于: 2020-11-14 06:18:27             🧑  作者: Mango


介绍

java.util.LinkedHashMap类是Map接口的Hash表和Linked list实现,具有可预测的迭代顺序。以下是有关LinkedHashMap的要点-

  • 该类提供所有可选的Map操作,并允许空元素。

  • HashMap上的迭代可能会更昂贵。

类声明

以下是java.util.LinkedHashMap类的声明-

public class LinkedHashMap
   extends HashMap
   implements Map

参量

以下是java.util.LinkedHashMap类的参数-

  • K-这是此映射维护的键的类型。

  • V-这是映射值的类型。

类的构造函数

Sr.No. Constructor & Description
1

LinkedHashMap()

This constructs an empty insertion-ordered LinkedHashMap instance with the default initial capacity (16) and load factor (0.75).

2

LinkedHashMap(int initialCapacity)

This constructs an empty insertion-ordered LinkedHashMap instance with the specified initial capacity and a default load factor (0.75).

3

LinkedHashMap(int initialCapacity, float loadFactor)

This constructs an empty insertion-ordered LinkedHashMap instance with the specified initial capacity and load factor.

4

LinkedHashMap(int initialCapacity, float loadFactor, boolean accessOrder)

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

5

LinkedHashMap(Map m)

This constructs an insertion-ordered LinkedHashMap instance with the same mappings as the specified map.

类方法

Sr.No. Method & Description
1 void clear()

This method removes all of the mappings from this map.

2 boolean containsValue(Object value)

This method returns true if this map maps one or more keys to the specified value.

3 V get(Object key)

This method returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

4 protected boolean removeEldestEntry(Map.Entry eldest)

This method returns true if this map should remove its eldest entry.

方法继承

此类从以下类继承方法-

  • java.util.HashMap
  • java.util.AbstarctMap
  • java.util.Object
  • java.util.Map