+ 1
Is it actually possible to delay actions in java ?
Can we delay actions in java, for exemple when we run the code : "a" Prints instanlly, then "b" Prints after 1000ms so we see "b" 1 second after "a" ?
2 Answers
+ 12
You can, but not on Code Playground, as it does not provide a live console.
+ 3
Yes , it is possible to do such using Java. But I'm afraid you can't do it using the Code Playground environment provided here.
However to implement such , you will use the Thread.sleep(1000) method .
This will cause a delay of 1 sec.
A snippet of this is given below:
try{
System.out.println("a");
Thread.sleep(1000);
System.out.println("b");
}catch(Exception e){
}
I hope it helps.