I am new java user. Recently I have learned that out
(Which we use at System.out.println
) is a java standard output object.
My question is; I never created this object by myself or haven't found any code which creates this object. So how it is accessible to use?
And more over I think System
is a class name. If so, is out
a static member of the System
class, since we are accessing out
without creating a new object of System
class?
Yes, System is a class and out is a static member variable of that class.
public final class System {
public static final PrintStream out = ...;
public static final PrintStream err = ...;
public static final InputStream in = ...;
...
}
See the Java documentation for System class
yep, this lives on the System object:
public final static PrintStream out = null;
A good way to learn a language (and to have the right answers) is to look at the API source.
in System.java
...
public final static PrintStream out = null;
...
you don't need to create object in order to access static members
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With