Possible Duplicate:
Wrapper class and == operator
I have a puzzle from my friend. Here is it:
public class Test{
public static void main(String[] args){
Integer i = 1000; //10
Integer y = 1000; //10
System.out.println(i == y);
}
}
The result will be FALSE. That's right. But when replacing the i,y value by 10, the result is TRUE.
From what I've read, when the operator == is applied to reference variables, it will test whether they refer to the same object. I don't know why the results like that, but I guess the problem in numeric promotion. I really need a help. Thank every one.