Vector class hashCode()method example
Returns the hash code value for this Vector.
Vector class hashCode()method example. This example shows you how to use hashCode()method.This method Returns the hash code value for this Vector.
Here is the code:-
/*
* @Program that Returns the hash code value for this Vector.
* HashCode.java
* Author:-RoseIndia Team
* Date:-26-May-2008
*/
import java.util.*;
public class HashCode {
public static void main(String[] args) {
//Creating vector
Vector v=new Vector();
//Adding element to the vector
v.add("Rose");
v.add("India");
v.add("Rohini");
v.add("Girish");
//Creating Enumeration Interface
Enumeration e=v.elements();
System.out.print("Vector created is: ");
while(e.hasMoreElements())
{
System.out.print(e.nextElement()+"\t");
}
System.out.println();
//Returns the hash code value for this Vector
System.out.print("HashCode of the element at Specified index is: "
+v.elementAt(2).hashCode());
}
} |
Output of the program:-
Vector created is: Rose India Rohini Girish
HashCode of the element at Specified index is: -1841663399 |
|