equals
Write a method named equals
that accepts two arrays of integers as parameters and returns true
if they contain exactly the same elements in the same order, and false
otherwise.
Note that the arrays might not be the same length; if the lengths differ, return false
. Do not call Arrays.equals
in your solution.
For example, if the following arrays are declared:
int[] a1 = {10, 20, 30, 40, 50, 60}; int[] a2 = {10, 20, 30, 40, 50, 60}; int[] a3 = {20, 3, 50, 10, 68};
The call equals(a1, a2)
returns true
but the call equals(a1, a3)
returns false
.