我怎样才能延迟我的程序,以便在文本之间有停顿?

How can I delay my program so there's a pause in between text?

我的代码示例:

System.out.println("Why hello there!");
System.out.println("Welcome to 'Ancient Battles and Adventures!");
***DELAY WOULD GO HERE***
System.out.println("Now, what is your name?");
public class MyClass {
    public static void main(String[] args) {
        System.out.println("Why hello there!");
        System.out.println("Welcome to 'Ancient Battles and Adventures!");
        try {
            Thread.sleep(x);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("Now, what is your name?");
    }
}

您可以尝试此代码成功

class ex 
{ 
    public static void main(String args[])
    {
        System.out.println("Why hello there!");
        System.out.println("Welcome to 'Ancient Battles and Adventures!");
        try
        {
            Thread.sleep(1000);// here you can delay for one second
        }
        catch(Exception e) {
            e.printStackTrace();
        }

        System.out.println("Now, what is your name?");
    }
}