Question: Your Own Array-Based List Class Write your own array-based list class from scratch, using generics. You can either implement the GeneralList interface shown in this

Your Own Array-Based List Class

Write your own array-based list class from scratch, using generics. You can either implement the GeneralList interface shown in this chapter, or write your own interface. Either way, be sure to implement all of the common list operations.

public interface GeneralList {
//methods to be implemented
public void add(E element);//add element to the list
public void add(int index, E element);//add element to a secific index
public void clear();//clears the list
public boolean contains(E element);//searchs for a specific eleement
public E get(int index);//gets the element at a spacific position
public int indexOf(E element);//gets the first occurrence of the specific element
public boolean isEmpty();//determnes if te list is empty
public boolean remove(E element);//removes an element from the list
public E remove(int index); //removes the element at a specific index
public E set(int index, E element);//replaces the elementata specific index
public int size();//gets the size of the list
}

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!