LinkedHashMap class Methods in Java

java.util.LinkedHashMap

Hash table and linked list implementation of the Map interface, with predictable iteration order.

Some methods of LinkedHashMap class.


clear()This method removes all of the mappings from this map.


clone()This method returns a shallow copy of this HashMap instance: the keys and values themselves are not cloned.


compute(K, BiFunction)This method attempts to compute a mapping for the specified key and its current mapped value.


computeIfAbsent(K, Function)If the specified key is not already associated with a value attempts to compute its value using the given mapping function and enter it into this map unless null.


computeIfPresent(K, BiFunction)If the value for the specified key is present and non-null, attempts to compute a new mapping given the key and its current mapped value.


containsKey(Object)This method returns true if this map contains a mapping for the specified key.


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


entrySet()This method returns a Set view of the mappings contained in this map.


equals(Object)This method compares the specified object with this map for equality.


forEach(BiConsumer)This method performs the given action for each entry in this map until all entries have been processed or the action throws an exception.


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


getOrDefault(Object, V)This method returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.


hashCode()This method returns the hash code value for this map.


isEmpty()This method returns true if this map contains no key-value mappings.


keySet()This method returns a Set view of the keys contained in this map.


merge(K, V, BiFunction) If the specified key is not already associated with a value or is associated with null, associate it with the given non-null value.


put(K, V)This method associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced.


putAll(Map)This method copies all of the mappings from the specified map to this map.


remove(Object)This method removes the mapping for the specified key from this map if present.


remove(Object, Object)This method removes the entry for the specified key only if it is currently mapped to the specified value.


replace(K, V)This method replaces the entry for the specified key only if it is currently mapped to some value.


replaceAll(BiFunction): This method replaces each entry's value with the result of invoking the given function on that entry until all entries have been processed or the function throws an exception.


size()This method returns the number of key-value mappings in this map.


toString()This method returns a string representation of this map


values()This method returns a Collection view of the values contained in this map.


No comments:

Post a Comment