I have two variables that should be compared:
Double a = 1D;
Double b = 2D;
if (a > b) {
System.out.print("Ok");
}
In this case java will use autoboxing or compare two object’s references?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From section 15.20.1 of the JLS:
Section 5.6.2 starts with:
So yes, unboxing is performed.
>has no meaning for references themselves.More interesting is the
==case where both options would be possible – and in that case, if either operand is a primitive and the other can be converted via numeric promotion, then that happens… but if both are reference types, the reference comparison is performed. For example: