title: using an array for a switch case statement in java
body: <p>I'm making a game, and i want the controls to be editable. well, i've got that part down, but they are being read and changed in a .txt file. that is the way i wanted it to work for now. the values are stored as the key value (ie. KeyEvent.VK_W is equal to 83, so the value for the line is 83). I also have it reading the values and saving them to a String array variable in my core class. In my key event class, the one that handles the pushing of the keys, i have it refering to the array to check if a command key was pushed. i'm continuously getting this error: <code>case expressions must be constant expressions</code> when i try it. here is the WRONG code:</p>
  
  <pre><code>switch(key){
    case Integer.parseInt(commands[1]):
        ...
        break;
  }
  </code></pre>
  
  <p>and i get that error. the value of <code>commands[1]</code> is 83. it is the value for "W". here is my declaration of the variable:</p>
  
  <pre><code>for (int i = 0; i &lt; commands.length; i++) {
                  commands[i] = io.readSpecificLine(FILES.controlsFileFinalDir,
                          i + 1);
  }
  </code></pre>
  
  <p>and if i have it print out every value, it does work. i've tried making the array <code>final</code> but that didnt work. i've run across the solution before, about 2 years ago, but i cant find it again. does anyone have any ideas on how to fix this? thanks in advance!</p>