I need a way to write R1 or R[1] and refer to the same variable.
1 Answer
If you're trying to use the general pattern of having ALPHANUMBER and ALPHA[NUMBER] refer to the same variable, you can't do it. The square bracket notation in Java refers to an element in an array, while the first is just a general identifier that can refer to a variable.
In the specific case of creating two variables, one a direct reference and the other an element in an array, you can simply point r[1] = r1 (as long as r1 has been initialized).
Object R1 = R[1];