Home / Expert Answers / Computer Science / add-the-following-methods-to-the-myarraylist-class-be-sure-to-make-these-methods-work-with-the-gene-pa450

(Solved): Add the following methods to the MyArrayList class. Be sure to make these methods work with the gene ...



Add the following methods to the MyArrayList class. Be sure to make these methods work with
the generic type version of the MyArrayList. Do not submit code that relies on the Java ArrayList
or the Collections framework to support this portion of assignment. Think about what each
method needs to do, and make it work within your customized MyArrayList class.
a. count(x): Returns the number of occurrences of x in the list
b. lastIndexOf(x): Returns the last index of x in the list and -1 if x is not in the list
c. rotate(): Shift elements of the list so that the last item is now first and everything else
shifts right by one position
d. rotate(n): Shift elements of the list forward or backward depending on value of n. Be
sure to account for beginning and end of the list
 



We have an Answer from Expert

View Expert Answer

Expert Answer


Java Code: import java.util.ArrayList; import java.util.Collections; import java.util.List; public class MyArrayList { private int size = 0; private static final int DEFAULT_CAPACITY = 10; private Object elements[]; public MyArra
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe