Trying to make a method that takes in two int arrays then reports true if they are mirror images of each other, or false if they are not. Assuming both arrays are of the same length.
example:
data1:{1,2,3}
data2:{3,2,1}
==> true
data1:{1,2,3}
data2:{2,3,1}
==> false
everything I try is giving me an ArayIndexOutOfBoundsException with my "for loop".
This is the most recent code I tried:
public boolean mirrorImage(int[] data1, int[] data2){ boolean mirrors = true; int x = 0; int a = 0; int b = data2.length; while(x < data1.length){ if(data1[a] != data2[b]){ mirrors = false; break; } else{ a = a + 1; b = b - 1; } x = x + 1; } return mirrors; }