When you check the source code of System
class, you can see it is set via native method calls:
private static native void setOut0(PrintStream out);
문제
i understand that out is a field in System class and it reference some object of PrintStream as print(System.out.getClass());
returns class java.io.PrintStream.
also i presume declaration of out in System class should be something like public static PrintStream out;
My query here is what actually is the value of 'out' field in System Class.
it can not be like
public static PrintStream out = new PrintStream(System.out);
Just Curious
해결책
When you check the source code of System
class, you can see it is set via native method calls:
private static native void setOut0(PrintStream out);
다른 팁
The declaration of out is like this (taken from System src)
public final static PrintStream out = null;
and it is initialized in this method
private static void initializeSystemClass() {
...
setOut0(new PrintStream(new BufferedOutputStream(fdOut, 128), true));
...
which is called by JVM
out
is a static member in the System
class and is an instance of PrintStream
.
From System class
public static final PrintStream out;