In C/C++ I can easily address a pointer, as opposed to the memory/object it points to, by implying its address with the & operator. For example, I can store a pointer to an existing pointer as per follows:
int integer1, integer2; int *pointer = &integer1; int **pointerToPointer = &pointer; *pointerToPointer = &integer2;
Upon executing the above snippet, the value of "pointer" is directly modified by dereferencing the “pointerToPointer” address and ends up referencing integer2 as opposed to integer1.
As the pointer-to-pointer or reference-to-reference semantic is extremely useful when dealing with all kinds of pointer-centric data structures, I was wondering whether or not Java has an analogous mechanism.
I know I can change the value of a Java reference by explicitly assigning it an object address (e.g. reference = new object...), but is there any way I can store the address of the reference variable itself (not the address of the object it points to) for later use?