Hi, can anyone tell me what the mistakes in this class? Thanks in advance!
// NOTES: // 1. There are several mistakes that cause this class does not behave // properly, including silly mistakes, (what some have found to be) subtle mistakes, // and mistake(s) of omission. // The goal of this exercise is to find and correct // as many of those mistakes as possible. // 2. The "main" method is just a quick-and-dirty "unit test" of // the class. While the "main" method may or may not be a *thorough* test // of the functionality of this class, it is a *valid* test, // so there is no need to fix the "main" method. // 3. One clue to the intent of this class is to try to determine // what *should* print out at the end of the "main" method.
/* * This class is designed to be a key into hash tables so that * elements can be "looked up" if the two specified strings match. */
// The goal of this exercise is to find and correct // as many of those mistakes as possible
Well, as I'm not the person being tested - wouldn't I be subverting the goal of this exercise by telling you?
Asking for answers to assignment questions is not in the spirit of these forums, so though someone may well give you the answer you need, but its not likely. [ January 18, 2005: Message edited by: Paul Sturrock ]
This isn't even close to what I'd call an advanced question; I would call this one a beginner question. Therefore, I'm going to move this to the Java in General (Beginner) forum for further discussion.
But let me warn people not to simply hand over the answers: just give hints.
I'll start: how does the assignment operator "=" work in Java?
This looks strangely like a homework assignment. This means you are supposed to learn something from it. If we just do the assignment for you, then how are you supposed to learn?
Anyway, enough of my soapbox. I would suggest that you compile and run the program. You probably need to know what the program *should* do and then you can compare it to what the program actually does. It also will help if pretend that you are the computer and "execute" the program by hand. By this I mean that you should make a table with the variables. Look at each line of code (in the order the computer will execute it) and update the value of each variable in your table as they change.
If there are any specific issues that you run into as you do this, let us know. We will be more than happy to clarify any specific questions you have.