making text appear delayed

前端 未结 4 1938
故里飘歌
故里飘歌 2021-01-22 08:19

I want to make text appear in the following way:

H
wait 0.1 seconds
He
wait 0.1 seconds
Hel
wait 0.1 seconds
Hell
wait 0.1 seconds
Hello

But I\

4条回答
  •  长情又很酷
    2021-01-22 09:09

    Use the Thread.sleep function to pause execution.

    System.out.print("H");
    Thread.sleep(1000);
    System.out.print("E");
    ...etc
    

    Of course, you'd probably want to put all of that into a loop, but Thread.sleep is what you want

提交回复
热议问题