Whenever I try to run this method to compare arrays I always get an ArrayIndexOutOfBoundsException. What am I doing wrong?
public static boolean areIdentical(int[] m, int[] n) {
//write a loop that compares each individual element of the two arrays.
//if a mismatch is found, return false
boolean identical = false;
for(int x = 0; m.length > x || n.length > x; x++) {
if(m[x] == n[x]) {
identical = true;
} else {
identical = false;
}
}
return identical;
}