Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 * returntrue
if it was successfully able to insert an item. * @param item the item to be added to theCustomList
* @returntrue
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 theCustomList
at the * specified index (thus shuffling the other items to the right). If the index doesn't * yet exist, then you should throw anIndexOutOfBoundsException
. * @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 theCustomList
* @returntrue
when the item is added * @throws IndexOutOfBoundsException */ boolean add (int index, T item) throws IndexOutOfBoundsException; /** * This method should return the size of theCustomList
* based on the number of actual elements stored inside of theCustomList
* @return anint
representing the number of elements stored in theCustomList
*/ int getSize(); /** * This method will return the actual element from theCustomList
based on the * index that is passed in. * @param index represents the position in the backingObject
array that we want to access * @return The element that is stored inside of theCustomList
at the given index * @throws IndexOutOfBoundsException */ T get(int index) throws IndexOutOfBoundsException; /** * This method should remove an item from theCustomList
at the * specified index. This will NOT leave an emptynull
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started