can i compare the equality of a array with the arraylist of arrays?
i have arrays of type 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 the codes below
boolean isEqual=false;
for(int index=0; index<list.size(); index++){
if(list.get(index).equals(arrA)){
isEqual=true;
}
System.out.println(isEqual);
}
and knowing that arrB5 is equal to arrA but why is that i always get
false?? am i doing the comparison right?? please help me...
No comments:
Post a Comment