Java - Booleans

Booleans

boolean ok = true;
if (ok) { System.out.println("Yes"); }

Java has no truthy/falsy rules for numbers or strings—only boolean expressions are allowed in conditions.

Try it

  1. Rewrite !(a || b) using De Morgan’s law and test with sample values.
  2. Short-circuit demo: ensure the right side of || doesn’t run when the left is true.