Question: Java Coding Question: Create class called matching with following method: public static int[] matching(int[] match, int[] mainArray) The method returns an array of index values
Java Coding Question:
Create class called "matching" with following method: public static int[] matching(int[] match, int[] mainArray) The method returns an array of index values when the match array is found in the main array. The first value of the return array must be how many matches there are. If there is no match method returns an array of 0
This is what should happen when you run the following code: int[] mainArray = {9,1,5,6,7,5,6,8,5}; int[] match1 = {5}; int[] match2 = {5,6}; int[] match3 = {5,6,7}; int[] a1 = matching(match1, mainArray); int[] a2 = matching(match2, mainArray); int[] a3 = matching(match3, mainArray);
The output for array a1 is: [3,2,5,8]
The output for array a2 is: [2,2,5]
The output for array a3 is: [1,2]
Remember the first digit of the output array is how many matches there are.
Thanks in advance for help. Absolutely no more classes or imports can be added.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
