Java Iterator create unmodifiable Iterator
import java.util.Iterator; public class UnmodifiableIterator { public static <E> Iterator<E> wrap(final Iterator<E> iter) { return new Iterator<E>() { @Override/*from ww w. ja v a 2 s.co m*/ public boolean hasNext() { return iter.hasNext(); } @Override public E next() { return iter.next(); } @Override public void remove() { throw new UnsupportedOperationException("Remove not supported."); } }; } }