aspose file tools*
The moose likes Beginning Java and the fly likes Add method to hash table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Add method to hash table" Watch "Add method to hash table" New topic
Author

Add method to hash table

Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

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

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

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

Joined: Sep 29, 2008
Posts: 12617

Could you post the source again, as two separate code blocks, and explain the problem again? Thanks!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18909
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Add method to hash table