In Iterator
Sun added the remove method to remove the last accessed element of the collection. Why there is no add method to add a new element to the collection? Wh
I cannot think of any theoretical reason why add()
could not have been included in Iterator
. Just as the Iterator
can allow for elements being removed from the collection through itself, it could be designed to handle elements being added in the same way.
But I will say that in all my years of programming in Java -- over 15! -- I have never wanted an Iterator.add()
method. So I suspect it's simply not all that useful.