UnmodifiableIterator implements Iterator<E> { @Deprecated @Override public final void remove() { throw new UnsupportedOperationException(); } protected  UnmodifiableIterator(); @Deprecated @Override final void remove();  }
@Test public void testRemove() { final String[] array = {"a", "b", "c"}; Iterator<String> iterator = new UnmodifiableIterator<String>() { int i; @Override public boolean hasNext() { return i < array.length; } @Override public String next() { if (!hasNext()) { throw new NoSuchElementException(); } return array[i++]; } }; assertTrue(iterator.hasNext()); assertEquals("a", iterator.next()); try { iterator.remove(); fail(); } catch (UnsupportedOperationException expected) {} }