My question is why (i1==i2)=false,(i3==i4)=false and (i5==i6)=true?
public class comp {
public static void main(String[] args){
Integer i1 = 2001;
Integer i2 = 2001;
System.out.println((i1==i2) + " " + (i1.equals(i2)));
Integer i3 = 21;
Integer i4 = new Integer(21);
System.out.println((i3==i4) + " " + (i3.equals(i4)));
Integer i5 = 21;
Integer i6 = 21;
System.out.println((i5==i6) + " " + (i5.equals(i6)));
}
}
The results are as below:
false true
false true
true true
Thank You.