Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

=+How might you explain this phenomenon?

Answered: 1 week ago