The hashcode()
method of the AbstractMap
class is used to get the hash code value for the map.
The default hash code of a map is defined to be the sum of the hash codes of each entry in the map’s entrySet view.
Note: Refer to What is the hashCode method in Java? to learn more about hashcode in Java.
public int hashCode()
The method has no parameters.
The method returns the hash code value.
Let’s look at the code below:
import java.util.*;public class Main{public static void main(String[] args) {AbstractMap<String, String> abstractMap = new HashMap<>();abstractMap.put("hello-1", "Educative");abstractMap.put("hello-2", "edpresso");System.out.println(abstractMap.hashCode());}}
put()
method.hashCode()
method and printed.Free Resources