M
Michael T. Peterson
Hi all,
While running a non-threaded program (at least my program doesn't create any
threads), I sustained a ConcurrentModificationException. More specifically,
the code is a simple while-loop using an iterator on a vector - Here is the
code.
while( it.hasNext() == true )
{
NodeToken nt = (NodeToken) it.next();
CIMFlavor cimFlavor = this.getFlavor( nt.tokenImage );
flavors.add( cimFlavor );
}
If I implement this same logic using a for loop, the loop overruns its index
and throws a ClassCastException. NB: The vector contains 2 elements and the
value of the index when the ClassCastException is taken is 2 (i.e., looking
for a 3rd element).
Here is the version of Java I'm using:
java version "1.4.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)
Can someone help me understand what's going on here. Have I missed something
really basic?
Cheers,
Michael
While running a non-threaded program (at least my program doesn't create any
threads), I sustained a ConcurrentModificationException. More specifically,
the code is a simple while-loop using an iterator on a vector - Here is the
code.
while( it.hasNext() == true )
{
NodeToken nt = (NodeToken) it.next();
CIMFlavor cimFlavor = this.getFlavor( nt.tokenImage );
flavors.add( cimFlavor );
}
If I implement this same logic using a for loop, the loop overruns its index
and throws a ClassCastException. NB: The vector contains 2 elements and the
value of the index when the ClassCastException is taken is 2 (i.e., looking
for a 3rd element).
Here is the version of Java I'm using:
java version "1.4.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)
Can someone help me understand what's going on here. Have I missed something
really basic?
Cheers,
Michael