Przykład

public class ClassA {

public void methodA (Vector aVector) {

Enumeration e = aVector.elements();
while (e.hasMoreElements()) {

Object obj = e.nextElement();
// operacje na obiekcie obj...
}
}


Rozwiązanie
Unikaj stosowania wyliczeń do sterowania pętlą, używaj w tym celu iteratora.

public class ClassA {

public void methodA (Vector aVector) {

Iterator it = aVector.iterator();
while (it.hasNext()) {

Object obj = it.next();
// operacje na obiekcie obj...
}
}