0

Why are they false and true?

public class Equivalence { public static void main(String[] args) { Integer n1 = new Integer (47); Integer n2 = new Integer (47); System.out.println(n1 == n2); System.out.println(n1 != n2); } }

12th Sep 2019, 1:52 PM
Дмитрий
Дмитрий - avatar
1 Resposta
0
n1 and n2 store the reference code of different Integer class object like n1= @123Integer n2=@124Integer Than n1 ==n2 //is false and n1!=n2 //is true
12th Sep 2019, 2:23 PM
Prathvi
Prathvi - avatar