Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MyList.java public interface MyList { /** THE STUDENT MUST WRITE THE METHOD HEADERS. THE FIRST ONE IS DONE FOR YOU **/ /** * Appends the

image text in transcribedimage text in transcribed

MyList.java

public interface MyList { /** THE STUDENT MUST WRITE THE METHOD HEADERS. THE FIRST ONE IS DONE FOR YOU **/ /** * Appends the specified element to the end of this list * @param data * @return boolean */ public boolean add(E data); /** * Inserts the specified element at the specified position in this list. * Shifts the element currently at that position (if any) and any subsequent * elements by adding one to their indices. * @param index - index at which the specified element is to be inserted * @param data - element to be inserted * @return boolean * @throws IndexOutOfBoundsException - if the index is out of range (index size()) */ add /** * Removes all of the elements from this list */ clear /** * Returns true if this list contains the specified element * @param data * @return boolean */ contains /** * Returns the element at the specified position in this list * @param index * @return E */ get /** * Returns the index of the first occurrence of the specified element in this list * Return, or -1 if this list does not * contain the element * @param data * @return int */ indexOf /** * Returns the index of the last matching of the element in this list * Return -1 if no match * @param data * @return int */ lastIndexOf /** * Returns true if this list contains no elements * @return boolean */ isEmpty /** * Removes the element at the specified position in this list. * Shifts any subsequent elements by subtracting one from their indices. * @param index - index of the element to be removed * @return E - the element that was removed from the list * IndexOutOfBoundsException - if the index is out of range (index = size()) */ remove /** * Trims the capacity of this ArrayList instance to be the list's current size. An application can use this * operation to minimize the storage of an ArrayList instance. */ trimToSize /** * Returns the number of elements in this list * @return int */ size }

Instructions for MyArrayList Hopefully you were able to code along with the video to implement your own ArrayList. We will begin with that code and complete the class. Most of the methods were written in the video. The code is also available on Blackboard/Week 4 in MyArrayList.zip Your MyArrayList class where you will implement MyList begins like this: public class MyArrayList extends MyAbstractList implements MyList After the functionality is complete and the bugs are worked out, the next step is to make MyArrayList a generic typed class by adding parameterized data type. Of course, MyAbstractList and MyList will also need the conversion applied to them. For grading, the class header will be: public class MyArrayList extends MyAbstractList implements MyList An example was given of converting Couple.java to a parameterized data type class. In general, the steps are: Add syntax to the class, and possibly some method headers (your IDE will help you know) Change Object to E in definitions of parameters, return types, arrays, and variables Take care when creating new arrays. Though the code below has replaced object with E, we cannot create an array this way Ell mylist - new E[10] // cannot do this nstead, we must create an array of object references and then cast the array to E Ell mylist(Ell) new Object [101: // can do this Instructions for MyArrayList Hopefully you were able to code along with the video to implement your own ArrayList. We will begin with that code and complete the class. Most of the methods were written in the video. The code is also available on Blackboard/Week 4 in MyArrayList.zip Your MyArrayList class where you will implement MyList begins like this: public class MyArrayList extends MyAbstractList implements MyList After the functionality is complete and the bugs are worked out, the next step is to make MyArrayList a generic typed class by adding parameterized data type. Of course, MyAbstractList and MyList will also need the conversion applied to them. For grading, the class header will be: public class MyArrayList extends MyAbstractList implements MyList An example was given of converting Couple.java to a parameterized data type class. In general, the steps are: Add syntax to the class, and possibly some method headers (your IDE will help you know) Change Object to E in definitions of parameters, return types, arrays, and variables Take care when creating new arrays. Though the code below has replaced object with E, we cannot create an array this way Ell mylist - new E[10] // cannot do this nstead, we must create an array of object references and then cast the array to E Ell mylist(Ell) new Object [101: // can do this

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

Students also viewed these Databases questions

Question

=+3. What does this public know about your organization?

Answered: 1 week ago