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

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

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

namespace System {
  class out {
    static println ...         


        
19条回答
  •  旧时难觅i
    2020-11-27 12:17

    Because out is being called with the System class name itself, not an instance of a class (an object), So out must be a static variable belonging to the class System. out must be instance of a class, because it is invoking the method println().

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

提交回复
热议问题