Hello, this code is not running.
package countdown; import java.util.Timer; import java.util.TimerTask; public class counter { public static TimerTask run() { System.out.println("hello"); return null; } public static void main(String args[]) { Timer t = new Timer(); t.schedule(run(), 0, 1000); } }
This is the console message.
Exception in thread "main" java.lang.NullPointerException: Cannot read field "lock" because "task" is null
at java.base/java.util.Timer.sched(Timer.java:400)
at java.base/java.util.Timer.schedule(Timer.java:249)
at countdown/countdown.counter.main(counter.java:14)