Tuesday, 19 April 2011

Now another question with respect to above question is if accessing through iterator is slow then why do we need it and when to use it.

For loop does not allow the updation in the array(add or remove operation) inside the loop whereas Iterator does. Also Iterator can be used where there is no clue what type of collections will be used because all collections have iterator.

No comments:

Post a Comment