I know pointers don't exist the way they do in C, but I was wondering if something like this would be possible:
I have 5 global variables, r1 r2 r3 r4 r5, each initially initialized to null
I want to (1) find the variable that hasn't already been used, (2) assign something to it, and then (3) manipulate that variable later in the program. However, I don't know the status of the variables until code execution. To make up for this, I now have a bunch of if-else statements:
if(r1==null)
r1 = [something]
else if(r2==null)
r2 = [something]
else if(r3==null)
r3 = [something]
else if(r4==null)
r4 = [something]
else if(r5==null)
r5 = [something]
So far so good. But the problem is, I want to take the variable that was modified in the above code and use/modify that variable later in the program.
So say if r1 and r2 were NOT null, and r3 was null, r3 = [something]. I want to modify r3 later on in the program. In C/C++, I'm thinking I could have set up a pointer to r3 in the if-else statement. Then I could just modify r3 through that pointer later in the program.
Is this possible in Java? Thanks!
EDIT: forgot to mention, r1-r5 are Strings.
Fieldtype in the reflection APIs.r1-r5are just Strings?