System class: It contains several useful class fields and methods. It cannot be instantiated.
Facilities provided by the System class: standard input, standard output, and error output streams; access to externally defined properties and environment variables; a means of loading files and libraries; and a utility method for quickly copying a portion of an array.
out : public final static PrintStream out
println(): void java.io.PrintStream.println(String x)
Prints a String and then terminate the line. This method behaves as though it invokes print(String) and then println().
How it works?
System class contains public static final PrintStream outvariable which is used to call the public void println() method of Prinstream class.
How out initialized?
JVM calls the private static void initializeSystemClass() method which initializes it.
FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
setOut0(new PrintStream(new BufferedOutputStream(fdOut, 128), true));
Native method:
private static native void setOut0(PrintStream out);
No comments:
Post a Comment