Hi, I'm rather new to Java. I would like to know why the following code doesn't work. I'm trying to parse the String named "string". My delimiters are topic, location, presenter and end. I try to loop through the string to grab all three instances (you'll notice there are three topics). However, after the second loop, it resets itself and gives me the same output as the first pass. Any ideas?
First, outside of the loop, you extract the first item, but you don't print it...
Next, when you enter the loop, you remove the first item from the string, and you extract the second item. This (second item) is the first item that will be printed.
Next, on the next iteration of the loop, you remove the second item from the string. However, this is the orginal string, so all three items are still present, so you extract the first item again. This (first item) is the second item that will be printed.
Next, on the next iteration of the loop, you remove the first item from the string. However, this is the orginal string, so all three items are still present, so you extract the second item again. This (second item) is the third item that will be printed.
If your loop kept going, your program will be toggling between the first and second items...