I am trying to use TimeUnit in java but it just send me errors That’s how I wrote it
import java.util.concurrent.TimeUnit ;
public class Anything {
public static void main( String[] args ) {
System.out.println("hi");
TimeUnit.SECONDS.sleep(6);
System.out.println("hi");
}
}
Try this as your code have many syntax errors
as well as you are not handling Exception
during the call of TimeUnit.SECONDS.sleep(6);
, either use throws or surround this with try catch.
import java.util.concurrent.TimeUnit ;
public class Anything {
public static void main( String[] args ) throws InterruptedException {
System.out.println("hi");
TimeUnit.SECONDS.sleep(6);
System.out.println("hi");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With