Ok, if you know C++ then think of Java variables that stores object as a reference to the actual memory location of the allocated object.
It means that if I assign a variable holding an object to another variable, then the new variable is going to point (reference) the same memory location :
class Value {
int value = 0;
}
Value v1 = new Value();
println("v1 : " + v1.value);
Value v2 = v1;
println("v2 : " + v2.value);
v2.value = -5;
println("v2 value after change " + v2.value);
println("v1 value after v2 change " + v1.value);
Prints :
v1 : 0
v2 : 0
v2 value after change -5
v1 value after v2 change -5
Because v2 points to v1 therefore when you change v2, you change v1. That’s why we have the notion of copy in Java (and deep copy) in order to duplicate entire objects.
So storing the result of eventTable.get(0).get(0) to a variable is just storing a reference to that element! ![]()