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.
systemclass has few static fields provide java program access basic operating system facilities.outputstreamclass provides methods write binary data stream (such file or network connection).printstreamsubclass ofoutputstreamprovides methods print text , other types of variables (likebooleanorint) underlyingoutputstream. converts strings binary example (so can written out).system.outinstance ofprintstreamconnected standard output stream.the field
outinprintstream(unlikesystem.out) not static field. means need instance ofprintstreamaccess it.myprintstream.outratherprintstream.out.the field
outinprintstreaminstances underlyingoutputstreambeing wrapped.this intended implementations of
printstreamwrite binary output to.it
protected, accessible implementations.you cannot access
system.out.out(ormyprintstream.out) directly (but don't need to,system.outforwardwrite)
Comments
Post a Comment