Monday, February 16, 2015

How System.out.println() actually works in java ? #interview

System is a class name( class name begin with capital letter according to naming convention).
System is a final class,  and among it's functionality, are standard input, standard output and error output streams.

 out is a (public static final) variable of type PrintStream declared in the System class. PrintStream is another class.

Out is a static final member of the System class, and it's type is PrintStream. It is your standard output stream, that is ready to accept the output data to be sent to a console or any other destination.

 println() is an overloaded method defined in the PrintStream class.


So System class would be something like

class System
{
public static final PrintStream out;
//other things
}

and the PrintStream class

 class PrintStream
{
//variables defined
public void println()
{
//things it does
}

}


No comments:

Post a Comment

Creating mirror of BST