System out, in and err streams declared null

63 Views Asked by At

I looked at java.lang.System source code and found the following lines:

public final static InputStream in = null;
public final static PrintStream out = null;
public final static PrintStream err = null;

I know that a final reference can't be reassigned, and therefore methods calls such as "System.out.println" should cause a NullPointerException. On the other hand, I saw that System.setOut is implemented in C (well, setOut0), and wondered what magic is happening here, and how I could reassign a value to a final reference.

0

There are 0 best solutions below