Complete the TimerTask so that it prints "Hello World!"
Timers
Creating a TimerTask
Report a typo
Sample Input 1:
Sample Output 1:
Hello World!Write a program in Java 17
import java.util.Timer;
import java.util.TimerTask;
class TimerCode extends TimerTask {
public void run() {
//Add code here
System.exit(0);
}
}
public class Main {
public static void main(String[] args) {
Timer timer = new Timer();
TimerTask task = new TimerCode();
timer.schedule(task, 0L);
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.