Question: I need help with this Java question. Please provide the final code and output if possible. Part 1: More FancyArray methods Add the following instance
I need help with this Java question. Please provide the final code and output if possible.
Part 1: More FancyArray methods
Add the following instance methods to the FancyArray
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
and Consumer
then fa.forEach(c) should print 8 4 5 .
A method named replaceAll that takes a UnaryOperator
fa is a FancyArray
and UnaryOperator
then, as a result of saying fa.replaceAll(op), fa should represent [10, 6, 7]
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 isnt empty.
A method named sort that takes a Comparator super E> 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
Get step-by-step solutions from verified subject matter experts
