I can't figure out why the output is different.
The output is same only in the range -128 to 127.
public class Check {
public static void main(String[ ] args) {
Integer i1=122;
Integer i2=122;
if(i1==i2)
System.out.println("Both are same");
if(i1.equals(i2))
System.out.println("Both are meaningful same");
}
}
Output:
Both are same
Both are meaningful same
public class Check {
public static void main(String[] args) {
Integer i1=1000;
Integer i2=1000;
if(i1==i2)
System.out.println("Both are same");
if(i1.equals(i2))
System.out.println("Both are meaningful same");
}
}
Output: Both are meaningful same