Question: I need help with this Java question. Please provide the output to FancyArray.java if possible. Add the following methods to the FancyArray class: - public

I need help with this Java question. Please provide the output to FancyArray.java if possible.

I need help with this Java question. Please provide the output to

Add the following methods to the FancyArray class: - public void add(int index, E element): Inserts the specified element at the specified position in this FancyArray. Shifts the element currently at that position (if any) and any subsequent elements to the right. - public E remove(int index): Removes the element at the specified position in this FancyArray. Shifts any subsequent elements to the left to fill in the gap. Returns the element that was removed. Examples: - Suppose fa1 is a FancyArray representing [5, 10, 15, 20]. After we say fa1.add(2, 25), fa1 should represent [5, 10, 25, 15, 20]. - Suppose fa2 is a FancyArray representing [5, 10, 15, 20]. After we say fa2.remove(1), fa2 should represent [5, 15, 20]. Throwing exceptions: - The add(int index, E element) method should throw an IllegalStateException if the array is already full. Also, this method should throw an IndexOutOfBoundsException if the provided index is negative, or if it is greater than the size. Note that it is possible to add an element at index size, as long as the array isn't already full. - The remove(int index) method should throw an IndexOutOfBoundsException if the provided index is negative, or if it is greater than or equal to the size. Note: do not use ArrayList (or any other kind of List or Collection) in the FancyArray class. Additional Notes: Regarding your code's standard output, CodeLab will check for case errors but will ignore whitespace (tabs, spaces, newlines) altogether

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!