Question: MyList is the class name int capacity() returns the current capacity of the list boolean isEmpty() returns true if no items are in list (size
| MyList is the class name | |
| int capacity() | returns the current capacity of the list |
| boolean isEmpty() | returns true if no items are in list (size == 0) |
| int size() | returns the number of items in the list |
| boolean contains(TYPE e) | returns true if the list contains e |
| TYPE[] toArray(TYPE[] array) | moves items from the list into array and returns the array, note that array must have been instantiated to the size of the list (not the capacity) |
| void add(TYPE e) | adds item e to the end of the list, lengthening the list if necessary |
| void add(int index, TYPE e) | Inserts item e at position index moving items if necessary, if index is greater than current size, add e to the end of the list, if index is negative, insert e to the front of the list |
| boolean remove(TYPE e) | remove the first occurrence of item e from the list, moving elements if necessary, return false if e is not in the list, true otherwise |
| boolean remove(int index) | remove item at index from the list, moving elements if necessary, return false if there is no item at index |
| void clear() | remove all items from the list (set size to 0) |
| TYPE get(int index) | return item at index, null if there is no item at index |
| int set(int index,TYPE e) | replace item at index with e and return e, return null if there is no item at index (index less than 0 or greater than size) |
| int indexOf(TYPE e) | return the index of the first occurrence of e, -1 if it is not in the list |
| int lastIndexOf(TYPE e) | return the index of the last occurrence of e, -1 if it is not in the list |
| Iterator | return an iterator for the list |
| MyList() | sets the capacity to 10, growth factor is 2 (capacity doubles when necessary) |
| MyList(int c, int g) | sets capacity to c, growth factor is g (number of spaces to add when necessary) |



You will demonstrate your code with the following main function. It should be placed in a separate class, not the MyList class public static void main (String[] args) f construct a list MyList
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
