Posted by gordan
on March 4, 2010 at 2:26 AM PST
In JDK7, new methods to get empty iterators have been added, thanks.
But the (much more useful) methods:
public Iterator unmodifiableIterator(Iterator itr)
public ListIterator unmodifiableListIterator(ListIterator litr)
are still missing, have they been overseen ?
The point is, that these classes effectively already exist in the JDK as anonymous classes returned by the iterator() method of UnmodifiableCollection, so it would not make the JDK much larger by just adding the missing static methods !
The other point is that it is inefficient to create an unmodifiable collection if the only thing you need is an unmodifiable iterator. This is a new requirement caused by the introduction of the Iterable interface which no longer requires to have a Collection to get an Iterator.