Java tutorial
//package com.java2s; import java.util.Iterator; public class Main { public static <T> Iterator<T> readOnlyIterator(final Iterator<T> iterator) { return new Iterator<T>() { @Override public boolean hasNext() { return iterator.hasNext(); } @Override public T next() { return iterator.next(); } @Override public void remove() { throw new UnsupportedOperationException("read only iterator"); } }; } }