java short if code example

Example 1: java one line if else

statement ? true 	: 	false
  ^		  |	 ^			  ^
condition |   (instruction)
  		  |  If the statement:  
  		  |	is true | is false
--------------------------------------------------------------------------------
 Example:
int i = 10;

String out = i > 8 ? "Bigger than Eight!" : "Smaller than Eight!";
System.out.println(out);

Example 2: java shortest if else statement

(myNumber == 12) ? "true" : "false"

Example 3: one line if statement java

statement ? true : false