System.out.println() 这条语句大家很熟悉,可是我还不够理解它,我在一本书上看到这么一段话,请大家帮助我来理解它。
 
     “System.out.println()  这条语句是使用了类 PrintStream 的 println()。System.out 为类 System 的数据成员 out,它属于 PrintStream 类。PrintStream 类能将任意类型数据输出为字符串形式。  ”     System.out 为类 System 的数据成员 out,它属于 PrintStream 类。这句话好像有问题。out 是 System 的数据成员,怎么又属于 PrintStream 类呢? 请高手指点,谢谢!

解决方案 »

  1.   

    怎么不可以?public class System {
        PrintStream out;
    }成员和子类是两回事,楼主还是好好打基础吧。
      

  2.   

    同意一楼的。System.out是System的成员,而out是java.io.PrintStream的一个实例。
      

  3.   

    哦,现在我明白了 out 为 System 类的一个静态属性的意义了,可能是这样的
     
    定义的:  public class System
      {   static PrintStream out;
          ......
      }  这样定义,out 就称为了 System 的静态属性了。但它又是属于 PrintStream 类了。谢谢指教!
      

  4.   

    不用可能哦,直接看jdk的代码就知道了    /**
         * The "standard" output stream. This stream is already
         * open and ready to accept output data. Typically this stream
         * corresponds to display output or another output destination
         * specified by the host environment or user.
         * <p>
         * For simple stand-alone Java applications, a typical way to write
         * a line of output data is:
         * <blockquote><pre>
         *     System.out.println(data)
         * </pre></blockquote>
         * <p>
         * See the <code>println</code> methods in class <code>PrintStream</code>.
         *
         * @see     java.io.PrintStream#println()
         * @see     java.io.PrintStream#println(boolean)
         * @see     java.io.PrintStream#println(char)
         * @see     java.io.PrintStream#println(char[])
         * @see     java.io.PrintStream#println(double)
         * @see     java.io.PrintStream#println(float)
         * @see     java.io.PrintStream#println(int)
         * @see     java.io.PrintStream#println(long)
         * @see     java.io.PrintStream#println(java.lang.Object)
         * @see     java.io.PrintStream#println(java.lang.String)
         */
        public final static PrintStream out = nullPrintStream();