public static void main(String[] args) { System.out.println("Hello world!"); String hola = "Hola, mundo!"; System.out.println(hola); }
Here is what javap shows as parsing for this code:
0: getstatic
It seems that the second line is saved, while the first is simply passed directly to the method.
This was built using the Eclipse compiler, which may explain the differences in my answer and McDowell's.
Refresh . Here are the results, if hola declared final (the result does not matter aload_1 , if I read this right, then this line is saved and as you might expect):
0: getstatic
source share