0

Explanation

I'm pretty sure there are multiple ways to get this done but what's the simplest recommended way to insert a wait-time before executing the next code?

Below is a simple Hello World code and I've added few comments to make it easier to understand and visualize :)

Code

/* HelloWorld.java */

public class HelloWorld
{
    public static void main(String[] args) {
        //Code 1
        System.out.println("Hello World!");

       //Some Code which will wait 10 seconds before executing the next line.

        //Code 2
        System.out.println("Hello Again, We Meet After 10 Seconds!");
    }
}
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • Thanks alot for helping, I know one way to get this job done but its really messy and uses for loops, I'm just looking for something simple :) – Radioactive Coffe Aug 07 '16 at 22:14
  • @Vld I've used thread.sleep() in past, I think it doesn't allow a wait time between codes, its more off it stops the whole code in the end for given time – Radioactive Coffe Aug 07 '16 at 22:16
  • That _is_ what you want, isn't it? You want to print "Hello World!" wait for 10 seconds and print another thing. You want it simple, as well. It's exactly what `Thread.sleep()` does. You specify the time and the thread gets suspended for that long. – VLAZ Aug 07 '16 at 22:19

0 Answers0