Referring a variable with a variable in java
<p>I have got into a strange strange situation. I have 3 sets of strings like this</p>

<pre><code>String set1q1="something";    //associated with randomNum=1
String set1q2="something";
String set1q3="something";
String set1q4="something";
... and so on

String set2q1="something";    //randomNum=2
String set2q2="something";
String set2q3="something";
String set2q4="something";
... and so on

String set3q1="something";    //randomNum=3
String set3q2="something";
String set3q3="something";
String set3q4="something";
... and so on
</code></pre>

<p>All these strings are initialised only once. Now in my program i generate a random number between 1-3. I converted this random number into a string and stored it into a string called set.<br></p>

<pre><code>String set=randomNum.toString();
</code></pre>

<p>Now next intead of using "if-else" to send the data(if randomnum=1 send set1q1-5, if randomnum=2 then send set2q1-5), I want the appropriate data to be sent using one line.<br></p>

<p>For example: if random no 2 is chosen then set2q1 has to be sent where the "2" in between is has to be the value of "set"(which is defined above).</p>

<pre><code>set"set"q1    //where set can be 1,2,3
</code></pre>

<p>Is there any way to do this?</p>
