In short, reassigning a value (which means the = operator) to an existing link does not change the object indicating the source link.
A minor misunderstanding in Java is that people think these are two types of variables:
- Primitives (e.g. int, boolean, etc.)
- Links (e.g. Integer, Boolean, custom objects, etc.)
Java NEVER uses links. The word Link is incorrect.
In Java, instead of Pointers, they are used only for managing objects.
To better understand the shadow: http://javadude.com/articles/passbyvalue.htm
As for your case, even if you skipped the Java naming conventions (but this is another topic), you can solve your problem by doing:
void SetVar(Integer value) { this.A = value; }
Indeed, if you pass A as a local parameter (like you), this local parameter will represent a copy of the A reference , since Java focuses only on passed-by-value , so changing it does not affect the start link.
source share