0

我将如何使它在 System.out.println 之间有一个暂停,所以它不会立即全部溢出,

import java.io.*;
import java.util.Scanner;
public class tester {
public static void main(String[] args) {
    System.out.println("Stranger: Good morning");
    System.out.println("Stranger: you had a terrible Dream..");
    System.out.println("Stranger: what is your name?");
    System.out.print("Name:");
    Scanner kbReader = new Scanner (System.in); 
    String s = kbReader.next();
    System.out.println("Nice to meet you " + s);
    System.out.println("my name is Master Wizard.");
    System.out.println("");
    System.out.println("");
    System.out.println("");
    System.out.println("");
    System.out.println("");
    }
 }
4

1 回答 1

3

你可以尝试类似...

import java.util.Scanner;

public class Test {

    public static void main(String[] args) {
        System.out.println("Stranger: Good morning");
        delay(500);
        System.out.println("Stranger: you had a terrible Dream..");
        delay(500);
        System.out.println("Stranger: what is your name?");
        System.out.print("Name:");
        Scanner kbReader = new Scanner(System.in);
        String s = kbReader.next();
        System.out.println("Nice to meet you " + s);
        System.out.println("my name is Master Wizard.");
        System.out.println("");
        System.out.println("");
        System.out.println("");
        System.out.println("");
        System.out.println("");
    }

    public static void delay(int millis) {
        try {
            Thread.sleep(millis);
        } catch (InterruptedException exp) {
        }
    }
}

例如

于 2013-07-17T04:04:28.013 回答