A little bit different to avoid compiler doing too much
static String a() { System.out.print("a "); return "0"; }
static String b() { System.out.print("b "); return "1"; }
static int c() { System.out.print("c "); return 2; }
static int d() { System.out.print("d "); return 3; }
public static void main(String... args) {
System.out.println(a() + b() + c() * d());
}
output:
a b c d 016
and the disassembled code:
public static void main(java.lang.String...);
Code:
0: getstatic #2 // Field java/lang/System.out:Ljava/io/PrintStream;
3: invokestatic #10 // Method a:()Ljava/lang/String;
6: invokestatic #11 // Method b:()Ljava/lang/String;
9: invokestatic #12 // Method c:()I
12: invokestatic #13 // Method d:()I
15: imul
16: invokedynamic #14, 0 // InvokeDynamic #0:makeConcatWithConstants:(Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String;
21: invokevirtual #15 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
24: return
despite the operands being evaluated in left-to-right order, the multiplication is done first, the concatenation next.
Here the disassembled code from question:
System.out.println("g."+ " big " + 2*3);
Code:
0: getstatic #2 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #16 // String g. big 6
5: invokevirtual #15 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
confirms another-dave's answer and comment, the compiler simplified the whole operations to one string "g. big 6"
With int variables (0:a, 1:b, 2:c, 3:d):
System.out.println(a + b + c * d);
Code:
12: iload_0
13: iload_1
14: iadd
15: iload_2
16: iload_3
17: imul
18: iadd
19: invokevirtual #21 // Method java/io/PrintStream.println:(I)V