Consider the interface below: import java.util.NoSuchElementException; public interface MyList { public int getSize(); public void insert(E data) throws ListOverflowException; public E getElement(E data) throws NoSuchElementException; public boolean delete(E data); // returns false if the data is not deleted in the list public boolean search(E data); // returns index of data, else -1 is return } a. Use an array object to store the elements of the list object. The program should be able to show its size, get element, delete, and search from the array. b. If the array is full and an element is to be inserted, a new array object with a size that is twice than the “old” array will be created. All the elements of the “old” array will be copied to the new array before inserting the new element.
Consider the interface below:
import java.util.NoSuchElementException;
public interface MyList<E> {
public int getSize();
public void insert(E data) throws ListOverflowException;
public E getElement(E data) throws NoSuchElementException;
public boolean delete(E data); // returns false if the data is not deleted in the list
public boolean search(E data); // returns index of data, else -1 is return
}
a. Use an array object to store the elements of the list object. The program should be able to show its size, get element, delete, and search from the array.
b. If the array is full and an element is to be inserted, a new array object with a size that is twice than the “old” array will be created. All the elements of the “old” array will be copied to the new array before inserting the new element.
Step by step
Solved in 2 steps