If I am not wrong ..You have crated 4 Integer objects, when you compare object references using == then the values inside reference (which is something how to get object values from heap) is checked while when you use equals() method which is inherited by every class in Java you compare the values pointed by the reference variables.
So its not necessary that always your first condition evaluates to true.
but your second condition will always evaluate to true,(Till values are same.) cause equals() is overridden in Integer class. [ August 09, 2007: Message edited by: prateek chaudhari ]