+ 1
HOW I DO A DELAY IN JAVA ???
i want to put a delay on a program in java but i dont know. plz help https://code.sololearn.com/c8VwBerV2nsn/?ref=app
2 Answers
+ 5
public static void main(String[ ] args) throws InterruptedException
For more info:
https://docs.oracle.com/javase/7/docs/api/java/lang/InterruptedException.html
Unfortunately, it doesn't work as expected in the SoloLearn Code Playground.
This is the working code in action:
https://code.sololearn.com/c3FbfOsUDviJ/?ref=app
+ 4
And you can use
Thread.Sleep(5000);
public static void main(String... a)
{
---
here your code you want to run before
-----
try{
Thread.Sleep(5000);}
catch (Exception e)
{}
---
here that code you want to run after 5 sec
---
--
}
}
this might help you