The Conditional Operator
Another example:
System.out.println ("Your change is " + count +
(count == 1) ? "Dime" : "Dimes");
If count equals 1, "Dime" is printed, otherwise "Dimes" is printed
Previous slide
Next slide
Back to first slide
View graphic version