only if condition in ternary operator java code example Example: java ternary operator Object myObject = booleanExpression ? valueIfTrue : valueIfFalse;