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.

  1. system class has few static fields provide java program access basic operating system facilities.

  2. outputstream class provides methods write binary data stream (such file or network connection).

  3. printstream subclass of outputstream provides methods print text , other types of variables (like boolean or int) underlying outputstream. converts strings binary example (so can written out).

  4. system.out instance of printstream connected standard output stream.

  5. the field out in printstream (unlike system.out) not static field. means need instance of printstream access it. myprintstream.out rather printstream.out.

  6. the field out in printstream instances underlying outputstream being wrapped.

    this intended implementations of printstream write binary output to.

    it protected, accessible implementations.

    you cannot access system.out.out (or myprintstream.out) directly (but don't need to, system.out forward write)


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -