• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hash map storing

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I tried to dig into java with its source code. I found that Hash map stores its keys and values in an entry array. But i still didn't understand how the mapping is maintained between the key and its corresponding object.
Can anybody give me a clear picture on this

Thanks in advance
Shasi Sekar
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shasi Sekar wrote:But i still didn't understand how the mapping is maintained between the key and its corresponding object.
Can anybody give me a clear picture on this



java.util.Map.Entry
 
Shasi Sekar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeff Verdegan, thanks for your immediate reply

That's right its stored in a entry format. But my question is how a key recognizes its object after storing, Or for a hash map ,all keys and values are in the same bucket, How a key identifies its value object OR how a key refers to its object

Thanks
Shasi Sekar
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A bucket is a list (or array) of Entry objects. The hashCode() of our key tells us which bucket it's in. Then we search through that bucket. We look at each Entry object. If entry.getKey().equals(searchKey), then we've found the Entry object we're looking for, and entry.getValue() gets us the value.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic