mercredi 2 juin 2021

What is the difference between these two code methods of getting list element in java?

List<Integer> test = new  ArrayList();
if(test.get(1)==test.get(0)) //test.get(1)=955 and test.get(0)=955
...

Above condition results in false

List<Integer> test = new  ArrayList();
int a=test.get(1); // equals 955
int b=test.get(0); // equals 955
if(a==b)
...

The above condition returns true.

Please help

Aucun commentaire:

Enregistrer un commentaire