This progam aims to be a countdown timer for the last 10 seconds of a rocket take off
However Nothing is printed to the console at all.
It is meant to print something every second I have no idea what I am doing wrong.
Any help would be great
However Nothing is printed to the console at all.
It is meant to print something every second I have no idea what I am doing wrong.
Any help would be great
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
public class Rocket {
static int count = 10;
public static void main(String[] args) {
int delay = 1000; // milliseconds
ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent event) {
count--;
if (count == 0) {
System.out.println("Blast off");
System.exit(0);
} else {
System.out.println("**" + count);
}
}
};
new Timer(delay, taskPerformer).start();
}
}