I have arrays of integers:
int[] arrA = {1,2,3,4,5,6,7,8,9};
int[] arrB1= {7,3,4,1,5,8,9,2,6};
int[] arrB2= {9,5,1,4,7,6,8,2,3};
int[] arrB3= {4,6,1,3,8,9,5,7,2};
int[] arrB4= {2,3,1,5,8,9,4,6,7};
int[] arrB5= {1,2,3,4,5,6,7,8,9};
and all the arrBs are added to the list, as follows:
List<int[]> list= new ArrayList<int[]>();
list.add(arrB1);
list.add(arrB2);
list.add(arrB3);
list.add(arrB4);
list.add(arrB5);
and I want to compare the equality of the array arrA with the list of arrays and I did it using this code:
boolean isEqual=false;
for(int index=0; index<list.size(); index++){
if(list.get(index).equals(arrA)){
isEqual=true;
}
System.out.println(isEqual);
}
I know that arrB5 is equal to arrA but why is it that I always get false? Am I doing the comparison right?