I only just started learning
Java, so my advice may be wrong -- but...
Are you sure that the element returned by nextElement CAN be cast to an Integer type?
According to the Java docs, a ClassCastException is "thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance. For example, the following code generates a ClassCastException:
"
If the objects in Vector v are not Integers and cannot be cast to Integers, you'll get this exception. I'm not sure if you can cast the primitive type int to Integer.
Hope that helps -- Jake