Question: In Java, when two objects are compared using ==, their references are also compared. But what happens when they are compared using other relational operators? For instance:

```
 Integer a = new Integer(10);
 Integer b = new Integer(9);
 if (a >= b) {
  System.out.println("A is greater");
 }

```

When I run this, I get output as A is greater, why so? Do references not get compared or they do and it's just a coincidence?

Also, if one of the arguments is primitive, does the non-primitive one get unwrapped to primitive for such comparisons?

Answer: 
In your example, the `Integer`(s) are [unboxed](https://docs.oracle.com/javase/tutorial/java/data/autoboxing.html) to primitive `int`(s). There is no `<=` (or `>=`) comparison for reference types (without `Comparable`, `Comparator` or similar).
Like Elliot Frisch mentioned, the `Integer`s are unboxed to `int`s. Think of this like the object being casted from an Object to a primitive.

Here is the byte code from your Java, which shows that [`Integer.intValue`](https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#intValue--) is called to get the `int` out of the `Integer`:

```
# Create Integer
NEW java/lang/Integer
DUP
# Store 10 in the Integer
BIPUSH 10
INVOKESPECIAL java/lang/Integer.<init> (I)V 
ASTORE 1

# Create Integer
NEW java/lang/Integer
DUP
# Store 9 in the Integer
BIPUSH 9
INVOKESPECIAL java/lang/Integer.<init> (I)V
ASTORE 2

# Get Integer(10)
ALOAD 1
# Call Integer.intValue (returns int 10)
INVOKEVIRTUAL java/lang/Integer.intValue ()I
# Get Integer(9)
ALOAD 2
# Call Integer.intValue (returns int 9)
INVOKEVIRTUAL java/lang/Integer.intValue ()I 
# Compare 10 < 9
IF_ICMPLT L3

```