title: Can a string be converted to an instruction?
body: <p>This code in Java:</p>
  
  <pre><code>for (Integer x=1; x &lt;= 3; x++) {
      y = "array[" + Integer.toString(x) + "] = a" + Integer.toString(x) + ".getText();";
      System.out.println(y);
      }
  </code></pre>
  
  <p>prints out:</p>
  
  <pre><code>array[1] = a1.getText();
  array[2] = a2.getText();
  array[3] = a3.getText();
  </code></pre>
  
  <p>However, instead of having string y printed out I want it executed. How do I do this in Java?</p>
  
  <p>If this is not possible, is there another way to achieve what I want, different from using the 3 instructions?</p>
  
  <pre><code>array[1] = a1.getText();
  array[2] = a2.getText();
  array[3] = a3.getText();
  </code></pre>
  
  <p>For simplicity I have used 3 although I need 20 instructions. More importantly, I am trying to learn more about Java and am looking for a more elegant solution.</p>