title: A Switch Java problem : case expressions must be constant expressions
body: <p>I having a problem in my switch/case statement. The error says : "Case expressions must be constant expressions". I understand the error and I can resolve it using If but can someone tells me why the case expression must be constant in a switch/case. 
  A code example of my error :</p>
  
  <pre><code>public boolean onOptionsItemSelected(MenuItem item) {
      int idDirectory = ((MenuItem) findViewById(R.id.createDirectory)).getItemId();
      int idSuppression = ((MenuItem) findViewById(R.id.recycleTrash)).getItemId();
      int idSeeTrash = ((MenuItem) findViewById(R.id.seeTrash)).getItemId();
  
      switch (item.getItemId()) {
      case idDirectory:
          createDirectory(currentDirectory);
          break;
      case idSuppression:
          recycleTrash();
          break;
      case idSeeTrash:
          seeTrash();
          break;
      }
  
      return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p>Thx for your explanation !!</p>