我想更换:
System.out.println("It works properly");
作者:
PrintWriter myPrintWriter = new PrintWriter(System.out);
myPrintWriter.print("This text is not displayed on my screen");
[不幸的是,这第二个选项不起作用,我也不为什么。我正在从零开始学习Java,并且试图了解一些基本问题,概念,所以...请帮忙。对不起,我的英语;)
使用myPrintWriter.flush()
Demo:
import java.io.PrintWriter;
class Main {
public static void main(String[] args) {
PrintWriter myPrintWriter = new PrintWriter(System.out);
myPrintWriter.print("This text is not displayed on my screen");
myPrintWriter.flush();
}
}
输出:
This text is not displayed on my screen