Thank you all especially Henry and Marc for your guidance. It now makes abolute sense. Just correct me if what I have got is wrong:
The JLS states that in case of the Boolean equality operators the values are first unboxed and then their values are compared. Hence Boolean true == boolean true yields true.
In the same way when we have an Integer object and an int what happens is since int comes in the list of prmitives for which the values are compared only after unboxing; an Integer object with value 10 is the same as an int with an object 10
The above conclusion for Integer objects is based ont the following piece of code that I wrote to
test it out
public class testintobjects
{
public static void main(String[] args)
{
Integer intObject=10;
int intPrimitive=10;
if(intObject == intPrimitive)
System.out.println("The Integer object is equal to the int primitive");
else
System.out.println("The Integer object is not equal to the int primitive");
}
}
It gives me the follwoing output
The Integer object is equal to the int primitive
Press any key to continue...