[jdom-interest] another Iterator/ListIterator problem

Jens.Steiner at epost.de Jens.Steiner at epost.de
Mon Jun 24 10:50:38 PDT 2002

I have some problems with the Iterator i get with ListXY.iterator()
Given the following code, hasNext() seems to return true even if no next element exists. Thus the while goes into another loop and 
a null pointer exeption is thrown. The ehas.size() returns 1 but the while loop runs >=1 times. I use iterators this way every day. I 
have no idea, what the reason for this behaviour could be. Changing to ListIterator didn't change anything. If anyone encountered 
a similar problem and has a solution for it he would make my day. 

List ehas = system.getChildren("eha");
Iterator it = ehas.iterator();
while (it.hasNext())
  Element eha = (Element)it.next();

Jens Steiner

More information about the jdom-interest mailing list