<分区>
下面的代码发生了什么?
public static void main (String[] args) {
int x = 5;
x = x++;
System.out.println(x); // 5. So what happened to the ++?
}
我可以理解 x 被赋值为 5,因为我们告诉它在递增之前取值。
但是,它仍然必须进行递增,所以这是在临时值上完成的吗?
我不懂 Java 字节码,但它反汇编如下。
public static void main(java.lang.String[]);
Code:
0: iconst_5
1: istore_1
2: iload_1
3: iinc 1, 1
6: istore_1
7: getstatic #2 // Field java/lang/System.out:Ljava/io/PrintStream;
10: iload_1
11: invokevirtual #3 // Method java/io/PrintStream.println:(I)V
14: return
我看不到它在哪里创建临时文件。 到底发生了什么?