Monday 6 May 2013

How HashMap works in java? or How does get () method of HashMap works in Java?


  • HashMap works on principle of hashing. 
  • When we pass Key and Value object  to put() method on Java HashMap, HashMap implementation calls hashCode method on Key object and applies returned hashcode into its own hashing function to find a bucket location for storing Entry object. 
  • Important point to mention is that HashMap in Java stores both key and value object as Map Entry in bucket which is essential to understand the retrieving logic.  
  • If people fails to recognize this and say it only stores Value in the bucket they will fail to explain the retrieving logic of any object stored in Java HashMap. 

1 comment:

  1. How to get to Borgata Hotel Casino & Spa by Bus, taxi, biking
    Directions to Borgata Hotel Casino & Spa (Borgata Hotel 삼척 출장안마 Casino 부천 출장샵 & 과천 출장샵 Spa) with public 문경 출장마사지 transportation. The following transit lines have routes that 보령 출장샵 pass near

    ReplyDelete