title: Storing variable changes during a switch [Java]
body: <p>I am currently in the process of making a calculator for Android (I am not using any tutorials) and am running into an issue. </p>
  
  <p>I have this:</p>
  
  <pre><code>public void buttonOnClick(View v){
  
     int operation;
  
     switch (v.getId()){
        case R.id.one:
            numberBox.append("1");
            break;
        case R.id.two:
            numberBox.append("2");
            break;
        case R.id.plus:
            operation=1;
            break;
        case R.id.eq:
            if (operation == 1){
                // Print value
            }
        break;
        default:
            break;
      }
  
  }
  </code></pre>
  
  <p>Note that this is not the exact code, it is just a mockup.</p>
  
  <p>The problem is, with the scope of the case, when the operation is set to 1, it is not set publicly and when I go to read it in the equals case, it is set back to 0. </p>
  
  <p>How can I fix this problem?</p>