posted 20 years ago
I assume that you are tokenizing your "lastname, firstname" string with the delimiter "," yes? In which case you probably won't see the comma because it is a token, not an element. For example:
would create a tokenizer containing two elements ("lastname", " firstname") and one token (",").
A quick glance at the JavaDoc for StringTokenizer and you discover that the possible causes of a NoSuchElementException being thrown is is there are no more tokens in a tokenizers string. This code will throw that exception:
If you are accessing the contents of a StringTokenizer, make sure you access them in a safe way, e.g.: