Understanding Java’s Everyday System.out.println();

You used it for “Hello World”, but do you understand its true meaning?

, or S.O.P, is most commonly used printing function.

Let’s break it down further using our understanding of the language and more general OOP concepts.

1. System

is a class located in the java.lang.System package.

Though it cannot be instantiated directly due to its private constructor, it houses capabilities regarding standard IO, error streams, environment, the filesystem, and more.

2. out

is a static field of the System class.

Note that its static nature means it can be accessed without instantiating System, just like Math.PI.

out is of type , allowing it to output data to the “standard” output stream at any point. In most cases, this occurs in the form of displaying text in the environment’s command prompt.

3. printLn()

is a void method that outputs its parameter to the output stream, as previously described.

In typical Java fashion, printLn() is overloaded to accept multiple types, such as String, boolean, char, int, long, double, Object, etc.

A similar function, print(), belongs to the Out field that accomplishes the same purpose, but does not append the newline (‘\n’) character to the output stream.

It’s all OOP

Interesting… diving deeper into one of Java’s most fundamental functions leads us to encounter several core concepts of : Constructors, Visibility Modifiers, Static Fields, Overloading, and even more not mentioned here.

I challenge you to critically inspect your favorite language, finding how its design and architecture is showcased within code segments that are taken for granted.

‌‌‎Inquisitive student.‎‌‌ Aspiring engineer. Photography enthusiast. Curious stock trader.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store