LinkedHashMap hashCode() in Java

hashCode(): This method is available in java.util.LinkedHashMap class of Java.

Syntax:

int java.util.AbstractMap.hashCode()

This method returns the hash code value for this map. The hash code of a map is defined to be the sum of the hash codes of each entry in the map's entrySet() view.

Parameters: NA

Returns: the hash code value for this map.

Exceptions: NA

Approach

Java

import java.util.LinkedHashMap;

public class LinkedHashMaphashCode {

    public static void main(String args[]) {

        LinkedHashMap<String, Integer> linkedHashMap =
new LinkedHashMap<String, Integer>();

        linkedHashMap.put("Java", 1);
        linkedHashMap.put("Hello", 2);

        System.out.println(linkedHashMap.hashCode());

    }

}

Output:

71911155


No comments:

Post a Comment