Question: Please code these two parts for me, in Java!! (Part A): (Part B): Here's my code that you can use for reference, if you want:

Please code these two parts for me, in Java!!

(Part A):

Please code these two parts for me, in Java!! (Part A): (Part

(Part B):

B): Here's my code that you can use for reference, if you

Here's my code that you can use for reference, if you want:

want: Add the following two methods to the FancyArray class: - publicint indexOf(E e): returns the index of the first occurrence of ein this FancyArray; if e does not occur in this FancyArray, returns

Add the following two methods to the FancyArray class: - public int indexOf(E e): returns the index of the first occurrence of e in this FancyArray; if e does not occur in this FancyArray, returns 1. - public int lastIndexOf( Ee) : returns the index of the last occurrence of e in this FancyArray; if e does not occur in this FancyArray, returns 1. For example, if fa is a FancyArray representing [5,10,15,10,20], then: - fa.indexOf(10) should be 1 - fa.lastIndexOf(10) should be 3 - fa.indexOf(25) should be -1 - fa.lastIndexOf(25) should be 1 Note: If you wish, you can make the parameter type be Object instead of E. It doesn't really matter for this exercise. 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. - 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!