InterviewSolution
| 1. |
Why There Is Not Method Like Iterator.add() To Add Elements To The Collection? |
|
Answer» The sole PURPOSE of an Iterator is to enumerate through a collection. All COLLECTIONS CONTAIN the add() method to serve your purpose. There would be no point in adding to an Iterator because the collection may or may not be ordered. And add() method can not have same IMPLEMENTATION for ordered and unordered collections. The sole purpose of an Iterator is to enumerate through a collection. All collections contain the add() method to serve your purpose. There would be no point in adding to an Iterator because the collection may or may not be ordered. And add() method can not have same implementation for ordered and unordered collections. |
|