Thursday 8 May 2014

Vector : hashCode : Get the hash code

public int hashCode()
Returns the hash code value for this Vector.

import java.util.*;

class VectorHashCode{
 public static void main(String args[]){
  Vector<Integer> myVector;
  myVector = new Vector<> ();
  
  System.out.println("Elements in myVector");
  System.out.println(myVector);
  System.out.println("Hash Code is");
  System.out.println(myVector.hashCode());
  
  /*Add Elements to myVector*/
  myVector.add(10);
  myVector.add(11);
  myVector.add(12);
  
  System.out.println("\nElements in myVector");
  System.out.println(myVector);
  System.out.println("Hash Code is");
  System.out.println(myVector.hashCode());  
 }
}

Output
Elements in myVector
[]
Hash Code is
1

Elements in myVector
[10, 11, 12]
Hash Code is
39754

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment