Question: Given the Interface Code write a java class that implements this interface and show the working functionality in the main method: public interface CustomList {

Given the Interface Code write a java class that implements this interface and show the working functionality in the main method:

public interface CustomList { /** * This method should add a new item into the CustomList and should * return true if it was successfully able to insert an item. * @param item the item to be added to the CustomList * @return true if item was successfully added, false if the item was not successfully added (note: it should always be able to add an item to the list) */ boolean add (T item); /** * This method should add a new item into the CustomList at the * specified index (thus shuffling the other items to the right). If the index doesn't * yet exist, then you should throw an IndexOutOfBoundsException. * @param index the spot in the zero-based array where you'd like to insert your * new item * @param item the item that will be inserted into the CustomList * @return true when the item is added * @throws IndexOutOfBoundsException */ boolean add (int index, T item) throws IndexOutOfBoundsException; /** * This method should return the size of the CustomList * based on the number of actual elements stored inside of the CustomList * @return an int representing the number of elements stored in the CustomList */ int getSize(); /** * This method will return the actual element from the CustomList based on the * index that is passed in. * @param index represents the position in the backing Object array that we want to access * @return The element that is stored inside of the CustomList at the given index * @throws IndexOutOfBoundsException */ T get(int index) throws IndexOutOfBoundsException; /** * This method should remove an item from the CustomList at the * specified index. This will NOT leave an empty null where the item * was removed, instead all other items to the right will be shuffled to the left. * @param index the index of the item to remove * @return the actual item that was removed from the list * @throws IndexOutOfBoundsException */ T remove(int index) throws IndexOutOfBoundsException; }

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!