【发布时间】:2011-08-07 09:51:39
【问题描述】:
在这个程序中,第三个字符串永远不会被打印出来。为什么?
(此 Java 程序在 Ubuntu 10.10 上的 Eclipse Indigo 上运行。)
import java.io.PrintWriter;
public class Tester
{
static void nested()
{
PrintWriter object2 = new PrintWriter(System.out, true);
object2.println("second");
object2.close(); // delete this line to make all strings print
}
public static void main(String[] args)
{
PrintWriter object1 = new PrintWriter(System.out, true);
object1.println("first");
Tester.nested();
object1.println("third");
object1.close();
}
}
【问题讨论】:
标签: java console printwriter