What does System.out.println mean ? or How it is possible to say Class.object.method ?
System: System is a class which provides facilities like standard input,output and error stream.Apart from this System is final so can't be inherited.Constructor of System class is private, so System class can't be instantiated.
public final class System {
/** Don't let anyone instantiate this class */
private System() {
}
}
out : represents standard output stream which is already open to display output data.
out is an instance of PrintStream class defined as static member of System class.
Syntax is like :
public final class System {
public final static PrintStream out = nullPrintStream();
}
since PrintStream's instance is static member of class System , you can directly write System.out.
There is another way where you dont even have to write System.out.println instead you can write out.println,to know more please refer this link.
println : print the message and then terminate the line.
System.out.println("Hello");
System: System is a class which provides facilities like standard input,output and error stream.Apart from this System is final so can't be inherited.Constructor of System class is private, so System class can't be instantiated.
public final class System {
/** Don't let anyone instantiate this class */
private System() {
}
}
out : represents standard output stream which is already open to display output data.
out is an instance of PrintStream class defined as static member of System class.
Syntax is like :
public final class System {
public final static PrintStream out = nullPrintStream();
}
since PrintStream's instance is static member of class System , you can directly write System.out.
There is another way where you dont even have to write System.out.println instead you can write out.println,to know more please refer this link.
println : print the message and then terminate the line.
System.out.println("Hello");
No comments:
Post a Comment