aspose file tools
The moose likes Beginning Java and the fly likes Java Println Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Groovy Fundamentals video training course this week in the Groovy forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java Println" Watch "Java Println" New topic
Author

Java Println

Sankar Vaiyapuri
Greenhorn

Joined: Oct 10, 2011
Posts: 3

In System.out.println() the System is a Class and out is a static instance of PrintStream in System class. println() is a method in PrintStream class. So the method println() is called using System.out. But the out instance is static,final and it is initialized to null in System class. Then how it calls println() method?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 42698
    
  32
What makes you think it is initialised to null?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19993
    
  25

The Java source code from src.zip. From the source of java.lang.System:
However, elsewhere we see this:
This method in turn is called when the class is loaded:
And that's how in the end System.out is initially set.

Note that although System.in, System.out and System.err are final, the JVM still is able to change them through System.setIn, System.setOut and System.setErr. That's because it uses native code to do so, and the JVM can do a lot through native code that we can't.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Println