int x = 5, y = 10, z = 15;
x += y += z += 5;
System.out.println(x + " " + y + " " + z);
z += 5 → z = 20,表達式值為 20。y += 20 → y = 30,表達式值為 30。x += 30 → x = 35,表達式值為 35。結果:x=35, y=30, z=20。
在線運行:https://ideone.com/qedarn 輸出 35 30 20。
+= 右結合性。