Thanks in advance.
System is static class
System is a final class, but not static.
And about System.out :
The "standard" output stream. This stream is already open and ready to accept output data.
So, I don't see any problem here.
how come System.out is an Object.
System.out is a reference static variable which refer to instance of PrintStream class. That instance is prepared for you by your JVM.
[ July 07, 2005: Message edited by: George Bolyuba ]
out in the System class, is a static reference to a PrintStream object. So, when you say System.out, what you actually get is a reference to a PrintStream object (The PrintStream class contains methods like print(), println() etc.
First, top-level class cannot be declared as static.
Second, image that you could create an instance of System class. Still you have only one system on which your current code is running. So, every System object will represent the same system. What's the point?
Is it clear now or I just didn't get yout problem?
out is a public static final member variable of the System class. This means you can address it without having to create an instance of the System class. It will be initialized for you. It cannot be overridden or altered because it is final.
Hope this clears things up for you.
Originally posted by Abrahim Daver:
Thanx for your clarifaction, But still its a bit confusive(for me), if System is not static class, then why is it taken as System.out, instead of making an object of System Class and then associating out with it? Please put more light on this.
This is because out is static. It has nothing to do with whether System is static or not (which it isn't as others have pointed out).