how do i add a delay in java code example
Example: java pause 1 second
//deprecated in main thread:
try {
Thread.sleep(1000);//time is in ms (1000 ms = 1 second)
} catch (InterruptedException e) {e.printStackTrace();}
//please use bellow instead:
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
//what you want to do
}
}, 1000);//wait 1000ms before doing the action