Ternary Operator
In a single line of code, the Java ternary operator lets you assign a value to a variable based on a boolean evaluation. At its most basic, the ternary operator can be used as an alternative to the Java if/then/else syntax, but it goes far beyond that, and can even be used on the right hand side of Java statements.
Example implementations
//If testCondition is true, the value of valueIfTrue is assigned to result, if false, valueIfFalse is assigned.
result = testCondition ? valueIfTrue : valueIfFalse;
//result is assigned a value depending on how many cookies are in the jar
String result = "There "+((cookies>1) ? "are "+cookies : "is one cookie") + " in the jar.";