ArrayList nested iterators
How do I clone an Iterator so that I can use a nested iterator over an ArrayList?
The problem with the code sample below is the inner iterator (Iter2)
advances the outer iterator (iter) so that the outer iterator only examines the first cell in the ArrayList.
thanks,
greg
import java.util.ArrayList;
import java.util.Iterator;
public class CellGroup extends ArrayList<Cell> {
public boolean checkForBlanksOrDuplicates()
{
Iterator<Cell> itr = this.iterator();
while (itr.hasNext()) {
Cell cell = itr.next();
if ( cell.getSymbol().equals(" "))
return false;
String s = cell.getSymbol();
Iterator<Cell> itr2 = itr;
while (itr2.hasNext()) {
Cell cell2 = itr2.next();
if ( cell2.getSymbol().equals(s) )
return false;
}
}
return true;
}
}

