Question: MyList.java contains MyList interface. The implementations of the default methods addAll, removeAll, retainAll, toArray(), and toArray(T[]) are omitted in the MyList interface. Please implement these

MyList.java contains MyList interface. The implementations of the default methods addAll, removeAll, retainAll, toArray(), and toArray(T[]) are omitted in the MyList interface. Please implement these methods. MyArrayList class implements MyList interface and inherits those default methods even though you dont implement them in MyArrayList.java file. Note that you can utilize other methods defined in the MyList interface to implement those methods. Since those methods should be implemented beforehand in MyList.java, the MyArrayList.java file should not be modified.

public default Object[] toArray(){

// Left as an assignment

//Returns an array containing all of the elements in this list.

}

@Override

public default T[] toArray(T[] array){

// Left as an assignment

// Returns an array containing all of the elements in this list; the returned array

// is the specified array.

.

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!