File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hashtable

 
Ronald Pruitt
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone show me how to build a hashtable to test for some string values to see how they would hash into a table. It's late and I may not be to asking this just right.I want to make a test hashtable, insert some words and see where they are put in the table. would like the size of the table to be 101, but everytime I try to call what I've done I get an error saying I can't use [] to find the position. I can give you what I have for code but it's far from finished I fear.

If you can be of any help I thank you.
Ron
 
Frank Carver
Sheriff
Posts: 6920
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you are more used to C++/STL than Java, as the program above has a lot of other conversion issues too. In Java, a variable is just a reference, so you always need to initialize them before use. T is declared as a reference to a Hashtable, for example, but nowhere does it say T = new Hashtable(), so T is always null. Likewise for M which is never initialized and so remains at 0 (it may look as if it is initialized in one of the constructors, but that actually just assigns a value to a local variable which is then discarded).
 
Ronald Pruitt
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to thank you both, I am just getting started at this and I know there are a lot of problems with the code. Is there a way to write a hashtable without using Java's Hashtable class to solve the problem above?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic