Let's say I've made an instance of a class A which includes a field int value.
int D;
A test = new A();
test.value = 3;
I want to make a variable D which will be linked to this test value of the class instance. Whenever this value changes my variable D will change to. I can do that if I know the link. I could simply do the following when a change occurs :
D = test.value;
However, let's say that I want D to be linked to different values(from other instances, let's say test2, test3) as the program runs. In that case I could use switch statements and have a different command depending on the link.
switch (help_var):
    case 1:
        D = test.value;
        break;
    case 2:
        D = test2.value;
        break;
    case 3:
        D = test3.value;
        break;
A changing pointer would be very useful. As the program runs, my pointer will change. In C, I would do the following in every case:
D = *pointer;
Is there a way to put the (test.value) reference in a variable and use something like this in Java?
 
     
     
     
     
     
    