The hashCode() method is used to return the hash code value for this Vector.
Following is the declaration for java.util.Vector.hashCode() method
public int hashCode()
NA
The method call returns the hash code value(int) for this list.
NA
The following example shows the usage of java.util.Vector.hashCode() method.
package com.tutorialspoint; import java.util.Vector; public class VectorDemo { public static void main(String[] args) { // create an empty Vector vec with an initial capacity of 4 Vector<Integer> vec = new Vector<Integer>(4); // use add() method to add elements in the vector vec.add(4); vec.add(3); vec.add(2); vec.add(1); // let us get the hashcode of the vector System.out.println("Hash code :"+vec.hashCode()); } }
Let us compile and run the above program, this will produce the following result −
Hash code :1045631