This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Add method to hash table

 
Remaan Rem
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can any one help me with this code ..
It should add an item to the dictionary .. but when I print the hash table I get null for all the entries ..

So this is the add method :


 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks like one method out of an extraordinarily complicated class; I'm sure we can't figure out what's wrong by looking at this small sample, but I also doubt anyone would want to read through the whole thing if you posted it here.

One thing that's suspicious about this is that I see you creating two DictEntry objects; how come? In general I'd think you'd want to store a value in just one place, but here you seem to be creating two, and doing different things with each. That can't be good.
 
Remaan Rem
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I think that you're saying that I have two DictEntries because you were looking at both parts of the code.
When the first one above the line works perfectly.
However, the problem is with the hash table adding method.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you post the source again, as two separate code blocks, and explain the problem again? Thanks!
 
Paul Clapham
Sheriff
Posts: 21142
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remaan Rem wrote:
Can any one help me with this code ..
It should add an item to the dictionary .. but when I print the hash table I get null for all the entries ..


I don't see any code like this:

That might well explain why the contents of the HashTable array always remain null.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic