What's the meaning of System.out.println in Java?

后端 未结 19 766
谎友^
谎友^ 2020-11-27 11:49

Is this static println function in out class from System namespace?

namespace System {
  class out {
    static println ...         


        
19条回答
  •  清酒与你
    2020-11-27 12:30

    System.out.println();
    

    System is the class

    out is a variable in the System class and it is a static and variable type is PrintStream.

    Here is the out variable in System class:

    public final static PrintStream out = null;
    

    You can see implementation of System here.

    println() is a overloaded method in PrintStream class.

    PrintStream includes three overloaded printing methods, those are:

    1. print()
    2. println()
    3. printf()

    You can see implementation of PrintStream here.

    You cannot instantiate System class and it is child class of Object and the Object is the father(superclass) of every classes including classes that you defined.

    Here is what the oracle docs says:

    public final class System extends Object

    The System class contains several useful class fields and methods. It cannot be instantiated.

    Among the facilities provided by the System class are 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.

    Since: JDK1.0

    If you donot know what is meant by instantiate, read this questioh. It is C# question but the concept is same.

    Also, What is the difference between an Instance and an Object?

    If you donot know what is meant by overload read this quesiotn.

提交回复
热议问题