Java Utility Library

Java Vector - hashCode() Method



The java.util.Vector.hashCode() method returns the hash code value for the vector.

Syntax

public int hashCode()

Parameters

No parameter is required.

Return Value

Returns the hash code value for the list.

Exception

NA.

Example:

In the example below, the java.util.Vector.hashCode() method returns the hash code value for the given vector.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    
    //creating a vector
    Vector<Integer> MyVector = new Vector<Integer>();

    //populating vector
    MyVector.add(10);
    MyVector.add(20);
    MyVector.add(30);
    MyVector.add(40);

    //print hashcode of the vector
    System.out.print("Hash Code of MyVector is: ");
    System.out.print(MyVector.hashCode());
  }
}

The output of the above code will be:

Hash Code of MyVector is: 1241621

❮ Java.util - Vector