how to use sleep() in java code example
Example 1: java sleep in code
import java.util.concurrent.TimeUnit
TimeUnit.SECONDS.sleep(1);
or
TimeUnit.MINUTES.sleep(1);
Example 2: sleep() java
import java.util.concurrent.TimeUnit
try {
TimeUnit.SECONDS.sleep(1);
}
catch (Exception e) {
System.out.println("Oops! Something went wrong!")
}