I am a Beginner to programming. I have this unusual doubt:
Tell me the difference between
System is a class that has a few static fields to provide your Java program access to very basic operating system facilities.
OutputStream is a class that provides methods to write binary data into a stream (such as a file or network connection).
PrintStream is a subclass of
OutputStream that provides methods to print text and other types of variables (like
int) to an underlying
OutputStream. It converts Strings to binary for example (so that it can be written out).
System.out is an instance of
PrintStream that is connected to the standard output stream.
PrintStream is (unlike
System.out) not a static field. This means that you need an instance of
PrintStream to access it.
myPrintStream.out rather than
PrintStream instances is the underlying
OutputStream that is being wrapped.
This is intended for implementations of
PrintStream to write their binary output to.
It is also
protected, so that it is only accessible to those implementations.
You cannot access
myPrintStream.out) directly (but you don't need to, as
System.out will forward everything you