title: How do i represent a String object/variable as an array variable name in java?
body: <p>I have a function with one argument in it of type int and it includes the position, and I have to return an array matching to that position. E.G. position = 3 I have to return array arr4.</p>
  <p>Ok simple I can use a switch statement to easily handle this situation, but the thing is there are a total of 1000 arrays and which all will be called once in a run time, so writing switch will a crazy idea</p>
  <pre><code> public String Convert(String s, int position) {
          //s=s.toLowerCase();
          String result = &quot;&quot;;
          String array[]=null;
          String array2[]=null;
          String array3[]=null;
          String space = null;
  
          switch (position) {
              case 0:
                  array = arr1;
                  array2 = arr1a;
                  array3 = arr1b;
                  space = arr1c;
                  break;
  
              case 1:
                  array = arr2;
                  array2 = arr2a;
                  array3 = arr2b;
                  space = arr2c;
                  break; 
  ....
  </code></pre>
  <p>so I tried something like this to overcome this problem</p>
  <pre><code> array = &quot;arr&quot;+1;
  </code></pre>
  <p>but it didn't work as I thought and I don't know can I cast a string into an array name or something else.</p>
  <p>IS THERE ANY SOLUTION TO SOLVE THIS PROBLEM.</p>