Liutauras Vilda wrote:Welcome to the Ranch.
I have moved your topic to "Java in General" as it is too difficult for "Beginning Java".
Norm Radder wrote:How are you trying to debug the code to see what it is doing? I use print statements that print out the values of variables as their values are changed and as they are used. The print out will show you what the code is doing and help you find the problem.
Note: A helpful technique that goes with the above is to define a toString() method in the Node class so when a Node is printed, its contents will be formatted.
Another useful debugging tool is the Arrays class's toString method for formatting arrays for printing:
Norm Radder wrote:With normal debugging techniques it should be easy to find the problem and fix it.
What have you tried?
question is too big
I have a problem with the get()
it seems that I have gone with my 'runner' variable too far ....
Norm Radder wrote:
can you explain what this code from the get() method is supposed to do?
Note the else clause is missing {}s to enclose the code it controls. You should always use {}s with if, else and loops
want the get() method to print me all poissible values for my specefic key.
Norm Radder wrote:
That's a new meaning for a get() method's purpose. Normally a get() method would return the value associated with the key passed as argument.
Your get() method shows all the values in the hash bucket for the key that was passed as an arg. That may be a valid method for debugging, but it's not useful for someone trying to get the value associated with a key.
I have to change the code
Norm Radder wrote:
Yes. Each bucket in the array has a linked list of the key/value pairs for all the keys with the same hash code. The code needs to search the list for the key that matches the arg.
Norm Radder wrote:Maybe 10000 is too many for now. Try something smaller first, like 40. Print out the contents of the hashTable array and manually inspect that all the added elements are there.
The world's cheapest jedi mind trick: "Aw c'mon, why not read this tiny ad?"
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|