Question: I need help with this Java question. Please provide in Java, the code and output if possible. Add the following instance methods to the FancyArray

I need help with this Java question. Please provide in Java, the code and output if possible.

I need help with this Java question. Please provide in Java, the

Add the following instance methods to the FancyArray class from Homework 3. Do not use an ArrayList, List, or any kind of collection in these methods. 1. A method named forEach that takes a Consumer super E> and performs its action for each element of the FancyArray. For example, if fa is a FancyArray> representing [8,4,5], and Consumer c=e> System.out.print (e+ " ), then fa.forEach(c) should print 845 . 2. A method named replaceAll that takes a UnaryOperator and replaces each element of the FancyArray with the result of applying the operator to that element. For example, if fa is a FancyArray representing [8,4,5], and UnaryOperator> op =e>e+2 then, as a result of saying fa.replaceAll(op), fa should represent [10,6,7] 3. A method named max that takes a Comparator super E> and finds the maximum element in the FancyArray based on the comparator. Assume that the FancyArray isn't empty. 4. A method named sort that takes a Comparator and sorts the FancyArray on the basis of the comparator, using the selection sort algorithm

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!