我将如何制作它以便在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("");
}
}
答案 0 :(得分: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) {
}
}
}
例如