Java Vector hashCode() Example

The hashCode() method of java.util.Vector class will return the hashcode of the vector

Signature

public int hashCode() 

Returns the hashcode of the current vector

Example

The following example shows the usage of java.util.Vector.hashCode() method.

import java.util.Vector;

public class HashCodeMethodVectorExample 
{
    public static void main(String args[])
    {
     // create an empty Vector
        Vector vector1 = new Vector();
        
        // use add() method to add elements to the Vector
        vector1.add("Element1");
        vector1.add("Element2");
        vector1.add("Element3");
        
        //Get the HashCode of the Vector
        System.out.println("HashCode of the Vector \"vector1\" is :"+vector1.hashCode());
    }
}

Output

HashCode of the Vector "vector1" is :76174005

Leave a Reply

Your email address will not be published. Required fields are marked *