All About System.out.println Method In Java

From the day one while learning Java we use to give this command to print some value to console. It may be for output purpose or for debugging purpose.

Now let us understand what is System,what is out and what is println?

System is a built in class which is present in java.lang package. This class is of final modifier type so it can not be inherited to other class. or it can not be instantiated. This package defines a class called System.The System class holds a collection of static methods and variables.the standard input,output and error output of the java runtime are stored in in,out,err variables.

out is a static final field (ie, variable)in System class which is of the type PrintStream (a built-in class, contains methods to print the different data values).
static fields and methods must be accessed by using the class name, so ( System.out ). In a simple way ..out is a static member of type PrinStream class(java.io) declared in the System class.static members of a class can be accessed directly by classname that’s why System.out.out here denotes the reference variable of the type PrintStream class. As this is of type static ,

println() is a public method in PrintStream class to print the data values. Hence to access a method in PrintStream class, we use out.println() (as non static methods and fields can only be accessed by using the reference variable)

Note- There are multiple println() method exists with different parameter

I am the founder and owner of the blog - TechTravelHub.com, always love to share knowledge on test automation,tools,techniques and tips.I am a passionate coder of Java and VBScript.I also publish articles on Travel ideas and great honeymoon destinations.Apart from these, I am a gear-head,love to drive across India. I have shared lots of articles here on How to travel several parts of India.Customization of cars aka car modification is my another hobby.Get in touch with me on [email protected]