Ternary Operator

A single line if/else statement.

What is the Ternary Operator?

A single line if/else statement.

double chocolate = 2.50;
double donuts = 3.99;

double maxPrice = (chocolate > donuts) ? chocolate : donuts;

Level: Apprentice · More Java terms at this level

Updated

In other subjects