public default <E2>void forEachRemaining(final Class<E2> endType,final Consumer<E2> consumer){
  try {
    while (true) {
      consumer.accept((E2)next());
    }
  }
 catch (  final NoSuchElementException ignore) {
  }
}

public default < E2 > void forEachRemaining ( final Class < E2 > endType , final Consumer < E2 > consumer ) { try { while ( true ) { consumer . accept ( ( E2 ) next ( ) ) ; } } catch ( final NoSuchElementException ignore ) { } }
a traversal can be rewritten such that its defined end type e may yield objects of a different type . this helper method allows for the casting of the output to the known the type .
