Trong chương trình này, chuỗi thứ ba không bao giờ được in. Tại sao?Tại sao một PrintWriter cục bộ can thiệp với một PrintWriter cục bộ khác?
(chương trình Java này được chạy trên Eclipse Indigo trên Ubuntu 10.10.)
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();
}
}