Ejemplo
public static class
ClassA
implements
Iterator {
//Otros métodos Iterator...
public
Object next () {
try
{
//...
}
catch
( Exception e ) {
// Manejar excepciones aquí
}
}
}
Solución
Reconsidere la funcionalidad de la cláusula catch. Asegúrese de que se genera java.util.NoSuchElementException cuando se produce un error
public static class
ClassA
implements
Iterator {
//Otros métodos Iterator...
public
Object next() {
try
{
//...
}
catch
( Exception e ) {
throw new NoSuchElementException();
}
}
return nextObj;
}