This is not possible with primitive types. You can achieve it with boxed Integers:
Integer a = new Integer(1);
Integer b = new Integer(1);
The <=
and >=
comparisons will use the unboxed value 1, while the !=
will compare the references and will succeed since they are different objects.