Tony Singarayar wrote:2. If we comparing primitives operands with == operator, I saw that code compiled fine when i compared int and float, shouldn't it fail to compile as int and float are different types.
Tony Singarayar wrote:1.When are the times autoboxing kicks in when using == operator?
Tony Singarayar wrote:Understood 100% about using == operator for comparing wrapper objects...
And understood about unboxing and then how == operator compares a wrapper object and a primitive...
Tony Singarayar wrote:ch1 == fl2 -> how is conversion happening here ? And how is the answer true? Can you please explain.
Tony Singarayar wrote:When we are comparing a 5-of char with 53-of float...How is the answer worked out to be true.?
Is any promotion done, If so, wouldn't it just make char to 5.0 and when compared with 53-float, shouldn't the result be just false?
The char uses an integer under the hood to store its value. So the char doesn't have '5' (char, single quotes) as value, but 53 (integer, no quotes). So both the char and the float have 53 as value (and these are considered equal).
Consider Paul's rocket mass heater. |