title: inner class non-final variable java
body: <p>I needed to change variables inside an inner class and I got the infamous "Cannot refer to a non-final variable inside an inner class defined in a different method" error.</p>
  
  <pre><code>void onStart(){
    bt.setOnClickListener(new View.OnClickListener() {
       public void onClick(View v) {
         int q = i;
       }
    });
  }
  </code></pre>
  
  <p>I quickly made a class that held all of the things I wanted to change and made a final version of the class outside the inner class</p>
  
  <pre><code>class temp{
    int q;
  }
  
  void onStart(){
    final temp x = new temp();
    bt.setOnClickListener(new View.OnClickListener() {
       public void onClick(View v) {
         x.q = i;
       }
    });
  }
  </code></pre>
  
  <p>This seems to be what I need and it works but I am wondering if this is how to correctly work around the problem. Also, I really hate using the word <code>temp</code> to name my class. Is there an actual programming term for what I did so that I make a more descriptive name for my class?</p>