Understanding Java class variable System.out?

I know this answer is correct. I'm concerned about understanding.

That means for me:

There's a class called Printstream, and it has a class variable called System. This class variable, System, itself has a class variable called out , which I call via System.out. Is that correct?

Let's continue to understand System.out.println(…):

https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/lang/System.html

I have now called the class System under Java docs

Field Summary: These are the attributes of the System class

Here I also find the attribute or field out

That means out is static => belongs to a class, here to System

final => Attribute out is not changeable

Printstream => This means that the attribute out itself has the data type Printstream

In the Printstream class there is the method println(…)

Right so far?

(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
6 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Destranix
1 year ago

For me:

There is a class printstream and this has a class variable system.

No.

There is a class “system” and it has a variable called “out” that is of the type “PrintStream”.
(In the past, the “PrintStream” class is written in the Camel case, not “Printstream”.)

Have now called the class system under Java docs

Field Summary: These are the attributes of the Class System

here I also find the attribute or Field
out

D. h. out is static => belongs to a class, here to system

final => Attribute out is not changeable

Printstream => D. h. the attribute
out has even the data type Printstream

In the printstream class there is the method println(…)

Right?

Yeah.

However, it is possible to change the stream iirc, but it may also be changed internally, so that the variable is not changed (but possibly forwarded to another stream).
EDIT: Okay, can also be that the Internal simply bend the reference under the hood. See: https://stackoverflow.com/questions/26903799/how-is-the-final-variable-system-out-changing-its-reference )

Destranix
1 year ago
Reply to  RedDevil1982

“if I recall correctly”

Destranix
1 year ago

But not confused with IRC. ๐Ÿ™‚

Schachpapa
1 year ago

“if I recall correctly”

cool;-)

MrAmazing2
1 year ago

There is a class printstream and this has a class variable system.

That’s wrong.
PrintStream has no class variable โ€œSystemโ€.

The rest is true.