I think what you require is a String array.
String[] strArray = new String[st.countTokens()]; // Create an array with no. of tokens as the size
int counter = 0; // Counter variable to be used as the arrays index.
while (st.hasMoreElements()){
//instead of printing the element I want to generate str[i] or something of the sort
strArray[counter++] = st.nextElement(); // add the element to the array
}
This way you can add all the tokens to a String array and then you can traverse through this array and compare the elements. Now to do some if-checks on each of those elements you need a loop. I used the standard for
loop since you're using Java 1.4.
for(int i=0; i<strArray.length; i++) {
if(strArray[i].equals("someString")) { // use equals method for string value comparisons.
// do something
}
}