Thursday, February 26, 2015

Java Basics

What is "out" on System.out.println() ?

In the System class "out" is an static final variable of class type i.e. it's an object of the "PrintStream" class. And this printsream class contains a definition of a public method called "println()".

here is the actual representation of the classes:

//the System class belongs to java.lang package
class System {
  public static final PrintStream out;
  //...
}

//the Prinstream class belongs to java.io package
class PrintStream{
public void println();
//...
}

No comments: