Delay in countown | SoloLearn: Learn to code for FREE!


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.

4/21/2020 9:26:52 PM

scorpio 2803

4 Answers

New Answer


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 import java.lang.Thread; ... int x = 100; while (x > 0) { Thread.sleep(1000); // 1 second System.out.println(--x); } ...


No, unfortunately not with the limitations of the playground.


I will try with other platform then.


Isn't any form of doing it here then? Thanks for helping.