Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inference Control In Statistical Databases From Theory To Practice Lncs 2316

Authors: Josep Domingo-Ferrer

2002nd Edition

3540436146, 978-3540436140

More Books

Students also viewed these Databases questions

Question

7. Senior management supports the career system.

Answered: 1 week ago