Originally posted by Brandt Charles:
1. While I understand StringTokenizer, per Java docs, is not recommended to be used, my instructors insist on requiring its use. Is each token considered data type String or StringTokenizer?
The type returned by nextToken() is String.
2. split() returns an array of strings, yet the length of an array cannot be increased (if I remember correctly) once it's been set. If I clear the previously split String array, and split another of the same name, will it allow a length large enough to accomodate the current number of elements? For example, say the first string splits into 3 elements. The next will be split into 5 elements. Will this generate an out of bounds exception or other error?
Each time you call split(), it will produce a new array. The size of the array doesn't change. You are correct that the size of an array cannot be increased once its created. However, a reference to an array can be assigned to refer to another array of that type as long as the reference isn't declared final.
[ July 05, 2006: Message edited by: Keith Lynn ]