Question
Must complete all methods. package list.exercises; import java.util.ArrayList; import java.util.List; @SuppressWarnings(serial) public class ExtendedArrayList extends ArrayList { /** * Counts the number of elements in
Must complete all methods.
package list.exercises;
import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("serial")
public class ExtendedArrayList extends ArrayList {
/**
* Counts the number of elements in this list that are equal to e.
*
* Uses .equals to check for equality.
*
* @param e the element to count
* @return the number of elements equal to e
*/
public int count(E e) {
return 0;
}
/**
* Rotates the list right n places.
*
* Rotating a list right means moving the last item to the front of the list:
*
* 1, 2, 3, 4, 5 when rotated right once becomes 5, 1, 2, 3, 4
*
* A list is rotated right two places as follows:
*
* 4, 5, 1, 2, 3
*
* and so on.
*
* @param n the distance to rotate the list right
*/
public void rotateRight(int n) {
}
/**
* Intersperses e between each existing element of the list.
*
* For example, given the list: "hey", "ho", "hi", if we intersperse "yo" we get:
* "hey", "yo", "ho", "yo", "hi"
*
* @param e the element to intersperse
*/
public void intersperse(E e) {
}
/**
* Returns a copy of this list in reverse order.
*
* This list is unmodified by this operation.
*
* @return a reversed copy of the list
*/
public List reversed() {
return null;
}
}
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