Answered step by step
Verified Expert Solution
Link Copied!

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 * 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Icdt 88 2nd International Conference On Database Theory Bruges Belgium August 31 September 2 1988 Proceedings Lncs 326

Authors: Marc Gyssens ,Jan Paredaens ,Dirk Van Gucht

1st Edition

3540501711, 978-3540501718

More Books

Students also viewed these Databases questions