Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is difference between Iterator and for loop

Answer Posted / amit r

There are basic 3 differences between For and Iterater.
1.
Using Iterater we can check if the object exists or not by using hasNext method. Where as in For Loop, there is not such method. Therefore, For Loop will be executed at fixed amount at every time.
2.
Using Iterator we can add or remove objects from the underlying collection. In For Loop, if we do so, concurrent modification exception will be thrown.
3.
Using Iterator we can move forward or backward where as For Loop can't.
:)

Is This Answer Correct ?    7 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is arrays sort in java?

966


Can we change the scope of the overridden method in the subclass?

1389


Is list thread safe in java?

921


What is the range of a character variable?

992


What is not thread safe?

984


How to perform quicksort in java?

1116


What is an argument java?

973


Can an abstract class be a final class?

995


What about member inner classes?

1096


Is char * a string?

992


What is the full meaning of java?

1042


Program to Find the second largest element in an array.

1188


How can we use primitive data types as objects?

961


Discuss 2D arrays.

1048


How to solve the problem of generating the unique hash keys with hash function?

1916