Question: Write a method named dataMatch() that takes as its parameter an array of integers and an ArrayList of integers, and returns true if the two
Write a method named dataMatch() that takes as its parameter an array of integers and an ArrayList of integers, and returns true if the two collections contain exactly the same values in the same order, and false otherwise.
Your solution should not create any additional arrays or ArrayLists, and should not modify the given array or ArrayList.
For example:
if array is {4, 1, 9} and list is [4, 1, 9], then dataMatch(array, list) should return true
if array is {3, 1, 9} and list is [3, 9, 1, 3], then dataMatch(array, list) should return false
if array is { } and list is [ ], then dataMatch(array, list) should return true
if array is {2, 2, 2, 2} and list is [2, 2, 2, 2, 99], then dataMatch(array, list) should return false
public static boolean dataMatch(int[] array, ArrayListlist) { // Write this implementation }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
