Creating a TimerTask

Report a typo

Complete the TimerTask so that it prints "Hello World!"

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);
}
}
___

Create a free account to access the full topic