How it works?

In "System.out", out is class variable of 'System' class. How it is possible for 'out' to refer to an object of 'PrintStream' class whereas an instance of PrintStream class should only be referenced by a variable whose data type is PrintStream.Can you kindly explain
[297 byte] By [New-Drop@Java-Seaa] at [2007-11-26 15:30:21]
# 1

> In "System.out", out is class variable of 'System'

> class.

>

> How it is possible for 'out' to refer to an object of

> 'PrintStream' class whereas an instance of

> PrintStream class should only be referenced by a

> variable whose data type is PrintStream.

>

> Can you kindly explain it?

System.out is a PrintStream. what did you think it was?

incidentally, PrintStream instances needn't be dereferenced as a PrintStream. any supertype of PrintStream can be used (google "polymorphism")

georgemca at 2007-7-8 21:46:57 > top of Java-index,Java Essentials,New To Java...
# 2
Just check out the javadoc for the System class, you'll easily find that System.out is a PrintStream, just look at the field summary. http://java.sun.com/javase/6/docs/api/java/lang/System.html
gimbal2a at 2007-7-8 21:46:57 > top of Java-index,Java Essentials,New To Java...