There is a code:
class A {
int x = 12;
}
public class Program {
public static void main(String [] args) {
A a = new A();
int d = 10;
a.x = d;
System.out.println("a.x: " + a.x + ", d: " + d);
d = 52;
System.out.println("a.x: " + a.x + ", d: " + d);
}
}
The output is:
a.x: 10, d: 10
a.x: 10, d: 52
Why a.x
doesn't change? As I understand during the assignment the left value take a reference of the right value, and if right value will changed after, the left value must change too. Why it doesn't happen?