Ternary operator. If myVariable does not equal null, the expression evaluates to myVariable. Otherwise, 5*.
Equivalent to:
myVariable == null ? 5 : myVariable
*Since myVariable is compared to null, this is clearly an object rather than a primitive, so the entire expression is expected to return an object, so technically this returns Integer.valueOf(5).
Ternary operator. If
myVariable
does not equalnull
, the expression evaluates tomyVariable
. Otherwise,5
*.Equivalent to:
*Since
myVariable
is compared tonull
, this is clearly an object rather than a primitive, so the entire expression is expected to return an object, so technically this returnsInteger.valueOf(5)
.