Confused about 'out's in System class and PrintStream class
Class System has a Class variable called out:
public static final PrintStream out
The "standard" output stream. This stream is already open and ready to accept output data. Typically this stream corresponds to display output or another output destination specified by the host environment or user.
and there is a instance variable 'out' in PrintStream class:
out
protected OutputStream out
The underlying output stream to be filtered.
Is there any sort of connection between them ?
Re: Confused about 'out's in System class and PrintStream class
Forget about the variable/field names. They don't exist at runtime.
System has a static field of type PrintStream.
That PrintStream, being a PrintStream, has an instance field of type OutputStream.
Do you still have a question?
db
Re: Confused about 'out's in System class and PrintStream class
System has a static field of type PrintStream.
That PrintStream, being a PrintStream, has an instance field of type OutputStream.
but the inctance field of type OutStream has nothing to with the static field of type PrintStream has, right ?
Re: Confused about 'out's in System class and PrintStream class
Of course it does.
It's an attribute of that PrintStream.
In fact it is the stream that is written to when you make calls to the PrintStream methods.
That Stream might itself wrap another stream, and so on, but that is all implementation details and shouldn't really affect how you use the PrintStream.