! flips a boolean: !true is false, and !false is true. !(condition) is true exactly when the condition is false.
!
!true
false
!false
true
!(condition)
!true // false !false // true !(5 > 3) // false (5 > 3 is true, ! flips it) !(2 > 5) // true (2 > 5 is false, ! flips it)
▶ Try it: run this, then change something and run it again.
What is !true?
What is !(5 > 3)?
!(5 > 3)
What is !(2 > 5)?
!(2 > 5)
True or false?
Sort each expression by its value.
Type exactly what this program prints.
public class Main { public static void main(String[] a){ System.out.println(!(4 > 2)); }}