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]

# 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
# 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.