Question
How to implement iterator. This is a java program. I have a boolean array and need to use an iterator although I am unsure of
How to implement iterator.
This is a java program. I have a boolean array and need to use an iterator although I am unsure of how to implement it. I don't need assistance in the BooleanArray class so will just share the portion for the variables. Thank you in advance for the help.
public class BooleanArray extends AbstractSet { private static final int DEFAULT_CAPACITY = 10;
private boolean[] data; private int manyItems;
}
I need help with thisIterator class.
private class thisIterator implements Iterator {
private int count = 0; // how many values have we seen (and not removed) private int currentIndex = -1;
@Override public boolean hasNext() { }
@Override public Integer next() {
if (!hasNext()) throw new NoSuchElementException("no more available"); return nextElement; }
@Override public void remove() { throw new UnsupportedOperationException("cannot remove element from bag");
} }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started