java - Why cant we use "PrintStream.out.println()" instead of "System.out.println()", as 'out' belongs to 'PrintStream' class? -
this question has answer here:
i beginner programming. have unusual doubt:
tell me difference between system.out
, printstream.out
, please.
system
class has few static fields provide java program access basic operating system facilities.outputstream
class provides methods write binary data stream (such file or network connection).printstream
subclass ofoutputstream
provides methods print text , other types of variables (likeboolean
orint
) underlyingoutputstream
. converts strings binary example (so can written out).system.out
instance ofprintstream
connected standard output stream.the field
out
inprintstream
(unlikesystem.out
) not static field. means need instance ofprintstream
access it.myprintstream.out
ratherprintstream.out
.the field
out
inprintstream
instances underlyingoutputstream
being wrapped.this intended implementations of
printstream
write binary output to.it
protected
, accessible implementations.you cannot access
system.out.out
(ormyprintstream.out
) directly (but don't need to,system.out
forwardwrite
)
Comments
Post a Comment