Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

iii.print out the arraylist iv.reverse all the elements v.print out this arraylist vi.make a clone of the arraylist vii.remove all the elements at any odd

image text in transcribed

iii.print out the arraylist iv.reverse all the elements v.print out this arraylist vi.make a clone of the arraylist

vii.remove all the elements at any odd index of the original arraylist (not the cloned one)

viii.print out the original arraylist ix.reverse the cloned arraylist x.print out the cloned arraylist (this arraylist should still contain the original sequence of elements in order)

xi.merge the cloned arraylist to the original arraylist (please think about what happens and draw a diagram for yourself to visualize it.)

xii.print out the original arraylist

1. Implement the arraylist ADT as MyArrayList class implements Cloneable) with the following public methods: a. append(Object element) - appending the element at the end of the arraylist b. clear() - make the arraylist collection empty C. contains (Object element) - check whether the arraylist contains the element d. elementat(int index) - access the element at the given index e. indexOf(Object element) - find the index of the element f. insert.At(int index, Object element) - insert the element at the given index g.isEmptyo - check whether the array list is empty h. removeAt(int index) - remove the element at the given index i. remove(Object element) - remove the element from the arraylist j. replace(int index, Object element) - replace the element at the given index with the given element k.size() - get the number of elements in the current arraylist 1. ensureCapacity (int minCapacity) - make sure the arraylist gets at least the given capacity m. clone) - returns a cloned copy of this arraylist n. removeRange(int fromIndex, int toIndex) - removes from this arraylist all of the elements whose index is between from Index, inclusive and toIndex, exclusive o.toString(- returns a string representation of this arraylist, containing the String representation of each element p. reverse() - reverse the elements in this arraylist 4. merge(MyArrayList arraylist2) - add all the elements in arraylist2 to the end of this arraylist 2. The MyArrayList class should be created in the collection package. 3. Your implementation should be a self-expanding arraylist, and behave like what we discussed in class. 4. After implementing the MyArrayList class you will test your MyArrayList class. To test the MyArrayList class you will create a Lab2 class under the lab package. 5. In the Lab2 class you will do the following: a. Search to find out what is the Fibonacci number sequence b. create a static method named test and do the following in this method i. create an instance of MyArrayList ii. add the first 25 Fibonacci numbers (starts with 0. 1. 1. 2. 3,5. 8. ...) into the arraylist based on the Fibonacci function, (not manually one by one, but by using a loop)

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

More Books

Students also viewed these Databases questions

Question

5. Identify three characteristics of the dialectical approach.

Answered: 1 week ago

Question

6. Explain the strengths of a dialectical approach.

Answered: 1 week ago

Question

4. Explain the strengths and weaknesses of each approach.

Answered: 1 week ago