Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The implementations of the methods addAll, removeAll, retainAll, toArray ( ) , and toArray ( T [ ] ) are omitted in the MyList interface.
The implementations of the methods addAll, removeAll, retainAll, toArray and toArrayT are omitted in the MyList interface. Implement these methods.
interface MyList extends java.util.Collection
Add a new element at the specified index in this list
public void addint index, E e;
Return the element from this list at the specified index
public E getint index;
Return the index of the first matching element in this list.
Return if no match.
public int indexOfObject e;
Return the index of the last matching element in this list
Return if no match.
public int lastIndexOfE e;
Remove the element at the specified position in this list
Shift any subsequent elements to the left.
Return the element that was removed from the list.
public E removeint index;
Replace the element at the specified position in this list
with the specified element and returns the new set.
public E setint index, E e;
@Override Add a new element at the end of this list
public default boolean addE e
addsize e;
return true;
@Override Return true if this list contains no elements
public default boolean isEmpty
return size;
@Override Remove the first occurrence of the element e
from this list. Shift any subsequent elements to the left.
Return true if the element is removed.
public default boolean removeObject e
if indexOfe
removeindexOfe;
return true;
else
return false;
@Override
public default boolean containsAllCollection c
for Object e: c
if this.containse
return false;
return true;
Adds the elements in otherList to this list.
Returns true if this list changed as a result of the call
@Override
public default boolean addAllCollection c
WRITE YOUR CODE HERE
Removes all the elements in otherList from this list
Returns true if this list changed as a result of the call
@Override
public default boolean removeAllCollection c
WRITE YOUR CODE HERE
Retains the elements in this list that are also in otherList
Returns true if this list changed as a result of the call
@Override
public default boolean retainAllCollection c
WRITE YOUR CODE HERE
@Override
public default Object toArray
WRITE YOUR CODE HERE
@Override
public default T toArrayT a
WRITE YOUR CODE HERE
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