Hi,
I tried the below code
Integer iObj1 = new Integer(100);
Integer iObj2 = new Integer(100);
if(iObj1 == iObj2)
System.out.println("Objects are equal!");
else
System.out.println("Objects are not equal!");
Predictably, the output is "Objects are not equal!".
Till jdk1.4, two wrapper objects, though both have same value are not considered as equal (==). We had to use the equals() method.
But from JDK1.5, using AUTOBOXING, we can use wrapper objects just like primitive datatypes.
The same piece of code when compiled in jdk1.5 should produce the output as "Objects are equal!".But when I compiled the abouve code with JDK 1.5,I am getting the output as "Objects are not equal!".
Can anyone help me in this regard??