Hi Guys, I need Clarification about System.out.println() . Here println() Method belongs to PrintStream class ,we can call a non static method by using an Object of that particular class. Here why we are not creating PrintStream class Object and How System,out,println() are related
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. For simple stand-alone Java applications, a typical way to write a line of output data is:
"out" is a static field of the System class. "out" is a PrintStream. Put another way, the out variable is a reference to an object of type PrintStream.
You do not have to create it because it is automatically created by the System class the first time the System class is referenced. So all we need to do is say:
and we can print things to the console (i.e. the screen).
Now although println is a non-static method, we are not calling it on a Class directly. Entering PrintWriter.println() would not work because we would then be calling println() -- a non-static method -- statically.