System.out.println() 这条语句大家很熟悉,可是我还不够理解它,我在一本书上看到这么一段话,请大家帮助我来理解它。
“System.out.println() 这条语句是使用了类 PrintStream 的 println()。System.out 为类 System 的数据成员 out,它属于 PrintStream 类。PrintStream 类能将任意类型数据输出为字符串形式。 ” System.out 为类 System 的数据成员 out,它属于 PrintStream 类。这句话好像有问题。out 是 System 的数据成员,怎么又属于 PrintStream 类呢? 请高手指点,谢谢!
“System.out.println() 这条语句是使用了类 PrintStream 的 println()。System.out 为类 System 的数据成员 out,它属于 PrintStream 类。PrintStream 类能将任意类型数据输出为字符串形式。 ” System.out 为类 System 的数据成员 out,它属于 PrintStream 类。这句话好像有问题。out 是 System 的数据成员,怎么又属于 PrintStream 类呢? 请高手指点,谢谢!
PrintStream out;
}成员和子类是两回事,楼主还是好好打基础吧。
定义的: public class System
{ static PrintStream out;
......
} 这样定义,out 就称为了 System 的静态属性了。但它又是属于 PrintStream 类了。谢谢指教!
* 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();