Solution: Loop It, Then Launch It!

  • public class Main – defines the class Main.

  • public static void main(String[] args) – main method where program execution starts.

  • for (int i = 1; i <= 10; i++) – a for loop that runs from 1 to 10, printing each number.

  • int countdown = 3; – initializes a variable countdown with the value 3.

  • while (countdown > 0) – a while loop that continues as long as countdown is greater than 0.

  • System.out.println("Countdown: " + countdown); – prints the current countdown number.

  • countdown--; – decreases countdown by 1 each loop iteration.

  • System.out.println("Go!"); – prints “Go!” after the countdown finishes.

Solution: Loop It, Then Launch It!

  • public class Main – defines the class Main.

  • public static void main(String[] args) – main method where program execution starts.

  • for (int i = 1; i <= 10; i++) – a for loop that runs from 1 to 10, printing each number.

  • int countdown = 3; – initializes a variable countdown with the value 3.

  • while (countdown > 0) – a while loop that continues as long as countdown is greater than 0.

  • System.out.println("Countdown: " + countdown); – prints the current countdown number.

  • countdown--; – decreases countdown by 1 each loop iteration.

  • System.out.println("Go!"); – prints “Go!” after the countdown finishes.