Hashtable hashCode() in Java

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

Syntax:

int java.util.Hashtable.hashCode()

This method returns the hash code value for this Map as per the definition in the Map interface.

Parameters: NA

Returns: the hash code value for this map.

Exceptions: NA

Approach

Java

import java.util.Hashtable;

public class HashtablehashCode {
    public static void main(String[] args) {
        Hashtable<String, Integer> hashtable =
new Hashtable<String, Integer>();

        hashtable.put("Hello", 1);
        hashtable.put("World", 2);

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

    }
}

Output:

153375779


No comments:

Post a Comment