Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am having trouble. please help me. Add iterator support to MyArrayList by following the steps below, - Create the class MyArrayListlterator , which implements

image text in transcribed

I am having trouble. please help me.

Add iterator support to MyArrayList by following the steps below, - Create the class MyArrayListlterator , which implements the Iterator interface. - MyArrayListlterator should contain the following data items, - "list" of type MyArrayList - "currentIndex" of type int, initially at zero - Make MyArrayList implement the Iterable interface by adding the iterator() method, which should return an instance of MyArrayListiterator. - Add the hasNext() and next() methods in MyArrayListlterator. - The hasNext() method should return true as long as currentIndex is less than the list size - The next() method should return the list's data item at index "currentIndex", and increment currentIndex You will have to fill in some of the blanks, such as handling exceptions and initializing the "list" member of MyArrayListlterator. Test it by creating an instance of MyArrayList, adding data to it, and using the enhanced for-loop to iterate through it and print out each data item. Turn in the following, - The source files (no zip file, just the individual .java files). - A screen shot of your program in action. It should show the result of the test run

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_2

Step: 3

blur-text-image_3

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

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

Distinguish between people-first and identity-first language.

Answered: 1 week ago