HashTable int hashCode() Method Example Program


Returns the hash code value for this Map as per the definition in the Map interface.

Program

package com.candidjava;

import java.util.Hashtable;

/**
 * @author: Hari Haran
 * @discription: The hashCode() method is used to get the hash code value for
 *               this Map as per the definition in the Map interface.
 */

public class HashTableHashCode {
	public static void main(String args[]) {
		Hashtable ht1 = new Hashtable();

		ht1.put(1, "Anand");
		ht1.put(2, "Hari Haran");
		ht1.put(3, "Kamal");
		ht1.put(4, "Karthikeyan");
		ht1.put(5, "Mohan");
		ht1.put(6, "Vinoth");
		ht1.put(7, "Hari Haran");

		System.out.println("Hash code value is :" + ht1.hashCode());
	}
}

Output

Hash code value is :1198854476

Explanation

public int hashCode()
Returns the hash code value for this Map as per the definition in the Map interface.
Specified by:
hashCode in interface Map
Overrides:
hashCode in class Object
Returns:
a hash code value for this object.


Related Post

Comments


©candidjava.com