Note that the docs for java.lang.System state specifically what it is, and it's almost always faster to look it up!
Joined: Feb 25, 2010
all I care and know about it is that it will output words to the command prompt and is really useful for debugging
Joined: Dec 24, 2009
Hardik Trivedi wrote:Hi all genius,
I know the use of System.out.println() and also know that System is a class and println() is a static method of some class.
But what is out in System.out.println()???
The System class contains several useful class fields and methods. The example of fields would be "out" field which is an object of PrintStream class ...and with the help of this field "out" we can call the method "println()"...which is available in class PrintStream....
The reason why we have to write this whole line to write or print a line is :
1. System is a final class, so you cannot extend it and the constructor of System class is private...so it cannot be instantiated too...that's why we use classname to call the System class instead of using the object name.
2. In System class there's a field known as "out" which is an object of class PrintStream and the reason why we cannot create an object of PrintStream directly is because PrintStream has got a parameterized constructor...which we don't need here...
3. With the help of this "out" object we can call the println() method in PrintStream class..to write a line on the command prompt..