I have a problem using Arraylists in java my code looks something like this:
List<Integer> numbers1 = new ArrayList<>();
List<Integer> numbers2 = new ArrayList<>();
boolean bcompare;
I add to the lists the same numbers, but when i try to compare the numbers of the index 0 of the lists like this the result of the boolean is false when it should be true:
bcompare = numbers1.get(0)==numbers2.get(0);
bcompare
is false
But here is the thing when I use some temp variables and then compare them it gives me what i expected, a true value on bcompare:
int a=numbers1.get(0);
int b=numbers2.get(0);
bcompare = a==b;
bcompare
is true
What am I doing wrong here?