//demonstrates AND/OR skipovers in a toggle "false && true || true" public class TestAndOr { //set the starting value of the light to true or false public static boolean lightIsOn = false; //main program public static void main(String[] args) { //print out the status of the light before toggling System.out.println("The light is " + lightIsOn); //perform the toggle of the light. //if lightIsOn is false, it breaks the AND and jumps straight to the rest of the OR. //if lightIsOn is true, it continues the AND and ignores the rest of the OR. if (((lightIsOn) && turnOffLight()) || turnOnLight()) { //everything happens in the condition so this is empty } //print out the status of the light after toggling System.out.println("The light is " + lightIsOn); } //function executed in main statement when light is on public static boolean turnOffLight(){ lightIsOn = false; return true; } //function executed in main statement when light is off public static boolean turnOnLight(){ lightIsOn = true; return true; } }