Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Interface:import java

Interface:import java

Computer Science

Interface: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);

}

Other than creating the interface shown above, the ListOverflowException class will have to be created. NoSuchElementException class is accessed from java.util package.

Filename: MyList.java

 

HELP:

Create implementations of the above interface in different ways as stipulated below.

a. Use an array object to store the elements of the list object. This array object will have a fixed size of five (5) and that an attempt to insert an element into the array when full will result to a ListOverflowException.

Filename: MyFixedSizeArrayList.java

 

b. Use an array object to store the elements of the list object. Although the initial size of the array is 5, this differs from the first situation because 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. You may refer to the illustration below.

Filename: MyGrowingArrayList.java

 

1.png

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE