Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown


Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am wondering what memory scheme is used to layout a Hashtable in Java. Is it the case that an array holds all the keys, and each key points to the address of it's corresponding value object which exists somewhere out there in memory? Or is it more like a two dimensional array, where each 'bucket' holds key/value pairs right next to each other? If anyone can help me understand this I would be grateful!
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In you JDK, you may find a file src.jar, which includes sample source for much of the standard library, including Hashtable.
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it is more like your first description.
A Hashtable is an array of Entry objects. Each Entry instance has several fields in it:
int hash;
Object key; // this refers to an entry in the KeySet
Object value; // this refers to a entry in the ValueSet
Entry next; //this refers to a entry in the EntrySet
However the Hashtable as a whole also has an Enumerator object and an Iterator object and several other tracking fields like counts and hashcodes etc.
So it gets quite compicated.

[This message has been edited by Cindy Glass (edited October 16, 2001).]
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic