1//Clear example with good readabilty
2String var = "Text";
3String shortHand = (var.equals("Text") ? "Returns this if true" : "Returns this if false");
4
5//Other example that is less readable
6int var = 9;
7int shortHand = var == 9 ? 1 : var++;
8
9//Pseudo code
10// CONDITION ? returns when true : returns when false
1statement ? true : false
2 ^ | ^ ^
3condition | (instruction)
4 | If the statement:
5 | is true | is false
6--------------------------------------------------------------------------------
7 Example:
8int i = 10;
9
10String out = i > 8 ? "Bigger than Eight!" : "Smaller than Eight!";
11System.out.println(out);
12