Question: 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

 1. Implement an ArrayList class that stores a list (of objects)

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

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!