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

Is call by reference possible in java?

965


Is java an ide?

985


How do you compare objects in java?

957


Explain the difference between extends thread vs implements runnable in java?

1132


do I need to use synchronized on setvalue(int)? : Java thread

1012


What is the difference between the file and randomaccessfile classes?

1099


What is java lang string?

987


What are streams?

1125


What are the advantages and disadvantages of object cloning?

1108


Differences between traditional programming language and object oriented programming language?

1125


Write a method to check if input string is palindrome?

1019


What do you understand by java virtual machine?

1198


Can we have multiple public classes in a java source file?

1193


which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?

11210


How does arraylist work in java?

1122