Im using a string tokenizer in my current class project, because I'm required too. heres the error message I am getting when I try and test the StringTokenizer,
I have no idea what any of this means, but here is my actual code so that maybe someone can point me in the direction of what I'm doing wrong thus far, because my text book is of no help, neither is my professor, because hes on springbreak. well here it is and thanks for any help in advance.
The init mentioned in the stack trace is a part of the constructor process. The null error probably means one of your arguments to new StringTokenizer was null. I didn't try to find where the arguments come from in your code, but you may need to edit the user's input or provide default values. Hope that helps!
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Feb 09, 2005
yeah I think I figured it out, will the program run into any more errors if I move the "new" StringTokenizer from the constructor to the spot where I'm using it?
The problem is that the StringTokenizer instance is tokenizing on the String "input". But since "input" is an instance variable intialized to null, the constructor attempts to tokenize "input", i.e. its tokenizing "null" which is why you get the NullPointerException. You should move the tokenizing out of the constructor because this constructor is called in the main() method where you create an instance of the class. However, at this point *(in your main method), "input" has not changed and is still null, and your constructor will being working on this variable even before you get input from the user. [ March 12, 2005: Message edited by: Kashif Riaz ]