#There is a delay() function?
24 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @keen glacier! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
You can use ‘Thread.sleep(milliseconds)’ to freeze the main thread. That will wait
it gave me this unreported exception InterruptedException; must be caught or declared to be thrown
Thread.sleep(1000);
1 error
Have you got to exception catching yet?
how i can do?§
one moment
try checking that out ^
I have this code line 39
In Java, you can deal with an exception in two ways, you can catch it, or you can throw it. Catching it would entail surronding the exception generating code in a try-catch block, which will trigger code in the catch section once an exception in throw. It'd look something like this try { Thread.sleep(1000); } catch (InterruptedException e) { //If the code fail and an exception is thrown, the code in this block will run e.printStackTrace(); }
ok so i can write like:
case 2: System.out.println("Macchina in spegnimento..."); try { Thread.sleep(1000); } catch (InterruptedException e) { //If the code fail and an exception is thrown, the code in this block will run e.printStackTrace(); } System.out.println("Macchina spenta!"); System.exit(0); //se è spenta il programma finisce break;
?
@slender compass
Yes
Thank you!
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
ok