System.out.println

S

sarathy

Hi all,
Can anyone explain what is the internal meaning of
"System.out.println()"

I guess "System" is a class in java.lang package ==> OK
When i reffered to the source code, i found "out" as

public final static PrintStream out = nullPrintStream();

I guess that this is a static reference variable of type
PrintStream. But how does it print to STDOUT ??? It is just initialized
with nullPrintStream() and since it is marked as final. this might the
only place where it is being assigned. [ i checked there were no static
initializers ]

My guess it that the println() method must be written in some
logic, such that it the stream is explicity mentioned then output in
that stream, else output to STDOUT

Similar is the guess for "in" and "err"

Is this guess right?

Regards,
Sarathy
 
M

Mike Schilling

sarathy said:
Hi all,
Can anyone explain what is the internal meaning of
"System.out.println()"

I guess "System" is a class in java.lang package ==> OK
When i reffered to the source code, i found "out" as

public final static PrintStream out = nullPrintStream();

I guess that this is a static reference variable of type
PrintStream. But how does it print to STDOUT ??? It is just initialized
with nullPrintStream() and since it is marked as final. this might the
only place where it is being assigned. [ i checked there were no static
initializers ]

in, out, and err are reset by native code, which doesn't respect final. See
System.initializeSystemClass().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,075
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top