I have seen in the System class that the out object (of type PrintStream) is initialized with a null value. How can we call method like System.out.prinln("");?
In System class out variable initialized like this way:
package java.lang;
public final class System {
public final static PrintStream out = nullPrintStream();
private static PrintStream nullPrintStream() throws NullPointerException {
if (currentTimeMillis() > 0) {
return null;
}
throw new NullPointerException();
}
}
As per shown above code out variable initialized by null and this variable is final, so it can not initialized further then how can we use "out" variable.