-1

I want to animate/time a few dots so they appear on the screen one-by-one. Here's my code:

else {
            System.out.print("Skipping the temperature check");
            System.out.print(".");
            System.out.print(".");
            System.out.print(".");
        }

I want the "Skipping the temperature check" line to be printed out first, and then the dots to appear one-by-one. Is there any way to do this?

  • Is your problem that you call `System.out.print(".");` and nothing prints? – CryptoFool Mar 27 '21 at 01:08
  • 1
    [How do I make a delay in Java?](https://stackoverflow.com/questions/24104313/how-do-i-make-a-delay-in-java) [Java Delay/Wait](https://stackoverflow.com/questions/8586137/java-delay-wait) [How to pause my Java program for 2 seconds](https://stackoverflow.com/questions/43507587/how-to-pause-my-java-program-for-2-seconds) [How can we add time delay in java programming?](https://stackoverflow.com/questions/28915531/how-can-we-add-time-delay-in-java-programming) – Jeff Matchett Mar 27 '21 at 01:13
  • Does this answer your question? [How to pause my Java program for 2 seconds](https://stackoverflow.com/questions/43507587/how-to-pause-my-java-program-for-2-seconds) – KevinO Mar 27 '21 at 01:40

1 Answers1

1

you can use thread sleep and new line character as below

System.out.print("Skipping the temperature check \n");
        Thread.sleep(1000);
        System.out.print(". \n");
        Thread.sleep(1000);
        System.out.print(". \n");
        Thread.sleep(1000);
        System.out.print(". \n");
        
sanjeevRm
  • 1,541
  • 2
  • 13
  • 24