Java LinkedHashMap class

Java LinkedHashMap class is Hash table and Linked list implementation of the Map interface, with predictable iteration order. It inherits HashMap class and implements the Map interface.

  • A LinkedHashMap contains values based on the key.
  • It contains only unique elements.
  • It may have one null key and multiple null values.
  • LinkedHashMap class declaration

    public class LinkedHashMap extends HashMap implements Map

    Constructors

    LinkedHashMap() It is used to construct a default LinkedHashMap.

    LinkedHashMap(int capacity) It is used to initialize a LinkedHashMap with the given capacity.

    LinkedHashMap(int capacity, float fillRatio) It is used to initialize both the capacity and the fillRatio.

    Method

    Object get(Object key) It is used to return the value to which this map maps the specified key

    void clear() It is used to remove all mappings from this map.

    boolean containsKey(Object key) It is used to return true if this map maps one or more keys to the specified value.

    EXAMPLE

    Flash Soon



    Advertisement

    © Sapster 2017