Timer does not start, is the null return type wrong. Or the return type must be new timertask.
package testing;
import java.util.Timer;
import java.util.TimerTask;
public class myClass {
public static TimerTask run() {
System.out.println("hello.");
return null;
}
public static void setTimer(int seconds) {
Timer timerObject = new Timer();
timerObject.scheduleAtFixedRate(run(), 0, 1000);
}
public static void main(String args[]) {
setTimer(1);
}
}