System.out.println("...") in Java code is translated into JVM. Looking into the JVM gave me better understanding what is going on behind the hood.
From the book Programming form the Java Virtual Machine. This code is copied from https://github.com/ymasory/programming-for-the-jvm/blob/master/examples/HelloWorld.j.
This is the JVM source code.
.class public HelloWorld
.super java/lang/Object
.method public static main([Ljava/lang/String;)V
.limit stack 2
.limit locals 1
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "Hello, world"
invokevirtual java/io/PrintStream/println
(Ljava/lang/String;)V
return
.end method
.end class
As "The JVM doesn't permit byte-level access to memory" the out
object in type Ljava/io/PrintSteram
; is stored in a stack with getstatic
JVM command.
Then the argument is pushed on the stack before called a method println
of the java/io/PrintStream
class from an instance named out
. The method's parameter is (Ljava/lang/String
;) and output type is void (V).