A guess - you try to call values.nextElement() twice in line #3 and lne #5. Can you try to make a single values.nextElement() and save it in a variable and use that?
You call nextElement() twice inside the loop. Use a variable to store the results instead:
Also, please KeepItDown - not only in posts but also in subject lines.
Thank you very much to both John Jai and Rob Spoor.
I followed your advice and it ran without problems. Right now, I want to convert from the while loop to for each loop to loop through values. The problem now is that values is of type Enumeration.
Vaues was earlier initialized as below:
With services being a custom reference type for the system I am trying to interface with. The services reference type has getValueEnumerator() method which returns a Enumeration of values. So I am tied to Enumeration. Is there a way to use for each loop.
You can write a wrapper class that implements Iterator and delegates its methods to a backing Enumeration (with remove() throwing an UnsupportedOperationException). However, doing so just to iterate in a slightly different way is rather pointless.
If you want to get rid of the while loop, you can turn it into a for loop already: