Question: Part 1 Prerequisite material Objectives Manipulating arrays and references Understanding when to useor equals 1 FindAndReplace Complete the implementation of the (static) class method Stringl


Part 1 Prerequisite material Objectives Manipulating arrays and references Understanding when to useor equals 1 FindAndReplace Complete the implementation of the (static) class method Stringl findAndReplace(Stringll in, Stringll what, Stringl] with) of the class Utils. The method returns a copy of the array in where each word occurring in the array what has been replaced by the word occurring at the corresponding position in the array with. The array designated by in must remain unchanged. Later in the semester, we will learn about exceptions. Exceptions provide tools for handling error situations. In the meantime, the method findAndReplace returns null whenever one of the preconditions of the methods is violated: In particular, the formal parameters cannot be null. For all three arrays, none of the elements can be null. The query and replacement arrays must be of the same length. You will hand in this exercise. Download and complete the starter file here: Utils java. public class Utils f Returns copy of therroy .in. where ch kond occurring in tha array uht' has been replaced by the Moru oing irn the sane pition in tha array 'with ram in an a ay of Strings param what an array of words to be replacod; perem with ai array of replacement words eturn a new array idententical to in oxcopt that all the occrroncos of words 4 found in 'what' have been replaced by the corresponding 0rd from 'With public static Striigl findAnuReplace Stringl in, Stringl what, Stringl with) String1 outnull; The new array to be returned boolean valid - true; // True f the pre conditions are satistified Testing pre-coition valid false nore or less 1 lines nissing if(valid ) { ut na Stringl in.length ] moro orlesselinas nissing Returning a refarence to tha newly creatod array that i contsins the same entries as in' except that sll the occurrancos of words fron 'what' have baon roplacod by their correspanding accurrence from 'with
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
