Question: Hi I need help with a CS lab. /** * Implements the cheat sheet's List interface. Implements generics. * The backing array is an array

Hi I need help with a CS lab.

/** * Implements the cheat sheet's List interface. Implements generics. * The backing array is an array of (E[]) new Object[10]; * @override toString() */ public class TJArrayList { private int size; //stores the number of objects private E[] myArray; public TJArrayList() //default constructor makes 10 cells { myArray = (E[]) new Object[10]; size = 0; } public int size() { } /* appends obj to end of list; increases size; must be an O(1) operation when size < array.length, and O(n) when it doubles the length of the array. @return true */ public boolean add(E obj) { } /* inserts obj at position index. increments size. */ public void add(int index, E obj) throws IndexOutOfBoundsException //this the way the real ArrayList is coded { if(index > size || index < 0) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); } /* return obj at position index. */ public E get(int index) throws IndexOutOfBoundsException { if(index >= size || index < 0) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); } /** * Replaces obj at position index. * @return the object is being replaced. */ public E set(int index, E obj) throws IndexOutOfBoundsException { if(index >= size || index < 0) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); } /* removes the node from position index. shifts elements to the left. Decrements size. @return the object at position index. */ public E remove(int index) throws IndexOutOfBoundsException { if(index >= size || index < 0) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); } /* This method compares objects. Must use .equals(), not == */ public boolean contains(E obj) { } /*returns a String of E objects in the array with square brackets and commas. */ public String toString() { } }

That is the shell code that I have to fill out with different methods. I keep getting errors so I decided to ask here. Thank you.

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!