Question: Given this code: public class IteratorApp { private void PrintAll(MyIterator myIter){ //code for printing ONE array } } int[] aList = {2,3,4,5,6,7,8,9}; double[] dList =

Given this code:

public class IteratorApp {

private void PrintAll(MyIterator myIter){

//code for printing ONE array

}

}

int[] aList = {2,3,4,5,6,7,8,9};

double[] dList = {1.2,2.3,3.4,4.5,5.6,6.7,7.8};

String[] slist = {"What", "me","worry?"};

public void run() {

MyIntIterator myIter = new MyIntIterator(aList);

MyDoubleIterator myDIter = new MyDoubleIterator(dList);

MyStringIterator mySIter = new MyStringIterator(slist);

PrintAll(myIter);

PrintAll(myDIter);

PrintAll(mySIter);

}

}

create an iterator for each array. All three iterators must share the same base type (that is, polymorphic). All iterators must implement First, Next, IsDone and CurrentItem operations.

Should have the following: main class, IteratorApp class, Iterator interface, MyIntIterator class, MyDoubleIterator class, MyStringIterator class.

OUTPUT should look like:

2

3

4

5

6

7

8

9

1.2

2.3

3.4

4.5

5.6

6.7

7.8

What

me

worry?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!