Tuesday 27 May 2014

LinkedList : hashCode : Get the HashCode of the list

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

import java.util.*;

class LinkedListHashCode{
 public static void main(String args[]){
  LinkedList<Integer> myList = new LinkedList<> ();
  
  System.out.print("Hash Code of myList is ");
  System.out.println(myList.hashCode());
  
  myList.add(10);
  
  System.out.print("Hash Code of myList is ");
  System.out.println(myList.hashCode());
 }
}

Output
Hash Code of myList is 1
Hash Code of myList is 41


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment