I don't know what I'm doing wrong, I have two lists of items and am trying to compare both of them.
private static void check_results(ArrayList<int[]> result2, int[] reversedList) {
//check results list for matches
System.out.println();
for (int[] item : result2) {
System.out.println(Arrays.toString(item) + " compared to " + Arrays.toString(reversedList));
if ( Arrays.toString(item) == Arrays.toString(reversedList))
{
System.out.println("we have a match!");
}
}
}
but I never seem to have a match. When I visibly compare, I can see they are matches.
[0, 0, 0, 20] compared to [0, 0, 0, 20]
... and so on
What am I doing wrong? I know result2
starts as an ArrayList but I iterate thought it so its a int[]
just like my variable reversedList
but I never get a match.