Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By Tolls

Thread: Confused about 'out's in System class and PrintStream class

  1. #1
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Confused about 'out's in System class and PrintStream class

    Class System has a Class variable called out:
    public static final PrintStream out
    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.

    and there is a instance variable 'out' in PrintStream class:

    out
    protected OutputStream out
    The underlying output stream to be filtered.

    Is there any sort of connection between them ?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: Confused about 'out's in System class and PrintStream class

    Forget about the variable/field names. They don't exist at runtime.

    System has a static field of type PrintStream.

    That PrintStream, being a PrintStream, has an instance field of type OutputStream.

    Do you still have a question?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Re: Confused about 'out's in System class and PrintStream class

    System has a static field of type PrintStream.

    That PrintStream, being a PrintStream, has an instance field of type OutputStream.

    but the inctance field of type OutStream has nothing to with the static field of type PrintStream has, right ?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: Confused about 'out's in System class and PrintStream class

    Of course it does.
    It's an attribute of that PrintStream.

    In fact it is the stream that is written to when you make calls to the PrintStream methods.
    That Stream might itself wrap another stream, and so on, but that is all implementation details and shouldn't really affect how you use the PrintStream.
    DarrylBurke likes this.

Similar Threads

  1. Replies: 16
    Last Post: 01-16-2012, 10:47 PM
  2. A little confused (class variable scope?)
    By Vase in forum New To Java
    Replies: 11
    Last Post: 02-03-2011, 02:51 AM
  3. Calling a class and a little confused
    By Boomer1 in forum New To Java
    Replies: 1
    Last Post: 12-29-2009, 06:10 PM
  4. Yet another Wrapper Class confused guy.
    By JAdeline in forum New To Java
    Replies: 2
    Last Post: 08-15-2008, 04:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •