0

The Java documentation page for the System class says that one of its fields is called "out":

static PrintStream out

If I then look at the doc page for the PrintStream class, it says that one of its inherited fields is called "out". If I then click on this particular "out hyperlink" on that doc page, it provides a bit more detail:

protected OutputStream out

I'm confused about these two variables called "out". Are they two completely seperate variables?

user2911290
  • 1,396
  • 1
  • 16
  • 26
  • Why bother reading this kind of obscure documentation, everyone knows the `System.out` is the standard outstream. – MightyPork Feb 01 '14 at 17:00

2 Answers2

1

Are they two completely seperate variables?

Yes, they are. PrintStream is a FilterOutputStream. As such it wraps an OutputStream object so that it can add behavior to it.

System.out

is referencing a PrintStream object that is wrapping the OutputStream (referenced by its own out field) that represents the standard output.

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
0

Of course they're completely separate. They're in different classes. QED

They also have different types.

user207421
  • 305,947
  • 44
  • 307
  • 483