I have this code:
class ABC
{
public static void main(String[] args) {
Integer inta = new Integer(10);
Integer intb = new Integer(10);
if (inta <= intb) {
System.out.println("inta is less than intb");
}
if (inta >= intb) {
System.out.println("inta is greater than intb");
}
if (inta != intb) {
System.out.println("inta is not equal to intb");
}
}
}
This outputs:
inta is less than intb
inta is greater than intb
inta is not equal to intb
Can anyone explain why this happens? How can an object be equal and not equal at the same time?