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 / a.jyotsna

The Iterator is not implemented as an
indexed loop, at least not in Sun Java. The collection
always has a
getter armed with the iterator's next value. Much of the
collection's
internal implementation is done via the iterator. But the
pieces of
ArrayList that are optimized for speed, skip bounds
checking and use int
array offsets to do their work.
I would like to know what is the difference between these 2.
>
> ArrayList list = new ArrayList
>
> for(int i=0; i<list.size(); i++){
> //do stuff
> }
>
> Iterator i = list.iterator();
>
> while(i.hasNext(){
> do stuff
> }

Is This Answer Correct ?    6 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you traverse a linked list in java?

1129


What is data movement?

1131


How to remove the trailing spaces from a string?

1274


What is the static import?

1104


Justify your answer that you can't define a method inside another method in java, if you can then how?

1170


Which api is provided by java for operations on set of objects?

1455


Which is fastest collection in java?

1081


What is the arraylist in java?

1051


Explain public static void main(string args[]) in java.

988


What is the difference between final, finally and finalize()?

1152


How does compareto method work?

962


What is complexity in java?

1041


What is floor in java?

1036


Difference between this() and super() in java ?

1078


What's the difference between int and integer in java?

1162