title: Is it possible to create variables at runtime in Java?
body: <p>For example, say I wanted to "extract" <code>String[] fruits = {"Pear", "Banana", "Apple"};</code> into three separate variables, eg:</p>
  
  <pre><code>for (int i=0; i != fruits.length; ++i) {
      // of course there's no eval in Java
      eval("String fruit + i = " + fruits[i] + ";"); 
  }
  
  // ie: code that creates something equivalent to the following declarations:
  String fruit0 = "Pear";
  String fruit1 = "Banana";
  String fruit2 = "Apple";
  </code></pre>
  
  <p>How could I do that, ignoring the <em>"Why the heck would you want to do that?"</em> question that you might be urged to ask me.</p>
  
  <p>Similar questions have been asked many times before, but the real answer was never given, because what the OP really needed was to use a different approach. That's fine, but is this possible at all? </p>
  
  <p>I have looked at reflection and it doesn't seem like there are any methods that would allow me even to add extra fields to an instance, let alone dynamically create locals.</p>