I want to compare a long value (primitive type) with another Long value (wrapper type):
long x = 5;
Long y = 5L;
// version 1: only safe, if x is a primitive type
var isEqual = x == y;
// version 2: y needs to be converted to its primitive type
var isEqual = x == y.longValue();
// version 3: using Object.equals(), x will be converted to its wrapper type
var isEqual = Objects.equals(x, y);
The question is: Is there any benefit in using version 2 instead of version 3?