Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Implement an ArrayList class that stores a list (of objects) using an array. Your class should have an append method to add an element

image text in transcribed

1. Implement an ArrayList class that stores a list (of objects) using an array. Your class should have an append method to add an element to the list. Your main method should demonstrate the use of the class and method, on Integers or instances of whatever class you like. 2. Add a toString method that returns a String representation of an ArrayList and use it in your main method. 3. Add a prepend method to add an element at the front of an ArrayList 4. Make your class generic by adding a generic type parameter and using it appropriately throughout the code. 5. The following code is the start of the LinkedList class described in lecture. public class LinkedList protected class Node public Object data; public Node next; protected Node first; Add the prepend method that adds a new Object to the front of the list. 6. Add a method indexOf (Object e) that returns the index of the given object in the list, or 1 if the object is not in the list. 7. Add a method get (int i) that returns the object at the given index in the list, or throws an IndexOutOfBoundsException if there is no such element in the list. 8. Add an instance variable last and use it to implement an efficient (fast) append method that adds a new Object at the end of the list. 9. Make your class generic by adding a generic type parameter and using it appropriately throughout the code

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

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions