+ 1

Delay in countown

I'm trying to do a countown using this program and I want to add some time delay between a number and the next. Right now it says all the numbers at once. int x=100; while(x>0) System.out.println(--x); Thank you.

21st Apr 2020, 9:26 PM
scorpio 2803
scorpio 2803 - avatar
4 Answers
+ 3
You can use Thread.sleep(milliseconds); However, this wil not work in the SoloLearn playground due to it giving all the output at once. You can run it on your own computer or in another interactive online compiler such as https://www.tutorialspoint.com/compile_java8_online.php. import java.lang.Thread; ... int x = 100; while (x > 0) { Thread.sleep(1000); // 1 second System.out.println(--x); } ...
21st Apr 2020, 9:38 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
No, unfortunately not with the limitations of the playground.
21st Apr 2020, 9:42 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
I will try with other platform then.
21st Apr 2020, 9:43 PM
scorpio 2803
scorpio 2803 - avatar
0
Isn't any form of doing it here then? Thanks for helping.
21st Apr 2020, 9:40 PM
scorpio 2803
scorpio 2803 - avatar