Ternary operator

Ternary operator — is a shorthand way of writing simple if-else statement.

result = (condition) ? value_if_true : value_if_false;
int age = 20;
String status = (age >= 18) ? "Adult" : "Minor";
System.out.println(status);

Ternary operator — Structure map

Clickable & Draggable!

Ternary operator — Related pages: