problem wit h arrayList iterator in loop

Hi,

ArrayLIst a1=a2;

Iterator it=a1.iterator;

infor loop

for(int i=0;i<2;i++){

while(it.hasNext())

it.next();

}

this is workingfor i=0; but i=1 it has not working

please give me solution

dont tell me thatthis solution

ArrayLIst a1=a2;

infor loop

for(int i=0;i<2;i++){

Iterator it=a1.iterator;

while(it.hasNext())

it.next();

}

please give any other solution

Message was edited by:

shannu

[996 byte] By [shannua] at [2007-11-27 3:59:26]
# 1
throws GarbledMessException
georgemca at 2007-7-12 9:03:57 > top of Java-index,Core,Core APIs...
# 2
1. What is the expected behaviour?2. What is the observed behaviour?3. Please indent your code nicely. It's great you use the code tags/button. It would be a further advantage to use it with your code only, not the entire message.4. What's wrong with your own
OleVVa at 2007-7-12 9:03:57 > top of Java-index,Core,Core APIs...
# 3

shaanu,

I think you dont have other feasible solutions for this issue.

Bcoz in each iteration in loop you have initialize the iterator , otherwise it

cannot fetch the list elements.

If you try to initialize the iterator only once , and try to access the iterator multiple times , it does not throw any exception but will display only one

set of list elements.

hari_honeya at 2007-7-12 9:03:57 > top of Java-index,Core,Core APIs...