Check to see if the array arr1 contain the same elements as arr2 in the same order in java.
for example:
isTheSame({\"1\", \"2\", \"3\"}, {\"1\",
You are iterating until you find a match. You should instead be looking for a String which doesn't match and you should be using equals
not ==
// same as Arrays.equals()
public boolean isTheSame(String[] arr1, String[] arr2) {
if (arr1.length != arr2.length) return false;
for (int i = 0; i < arr1.length; i++)
if (!arr1[i].equals(arr2[i]))
return false;
return true;
}
FYI This is what Arrays.equals does as it handle null
values as well.
public static boolean equals(Object[] a, Object[] a2) {
if (a==a2)
return true;
if (a==null || a2==null)
return false;
int length = a.length;
if (a2.length != length)
return false;
for (int i=0; i