I need to compare two different Arraylists of different sizes.
I can do this with two loops – but I need to use iterators.
The second loop only iterates once instead of n times.
while (it.hasNext()) {
String ID = (String) Order.get(i).ID();
j = 0;
while (o.hasNext()) {
String Order = (String) Order.get(j).ID();
if (myOrder.equals(Order)) {
//do sth
}
j++;
o.next();
}
i++;
it.next();
}
You can use iterators in a much simpler way than you do: