Hashtable hashCode Example
Hashtable class hashCode method example.public int hashCode() Returns the hash code value for this Map as per the definition in the Map interface.
Here is the code
/**
* @ # HashCode.java
* A class repersenting use to hashCode method
* of HashMap class in java.util package
* version 19 May 2008
* author Rose India
*/
import java.util.*;
public class HashCode {
public static void main(String args[]) {
Hashtable table = new Hashtable();
//Put value into the table
table.put(1, "A");
table.put(2, "B");
table.put(3, "C");
table.put(4, "D");
Hashtable table1 = new Hashtable();
table1.put(1, "A");
table1.put(2, "B");
System.out.println("Hash code of table :" + table.hashCode() +
"\nHash code of table1 :" + table1.hashCode());
}
} |
Output
Hash code of table :256
Hash code of table1 :128 |
|