Access local variable from inner class
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/7423028/java-local-variable-visibility-in-anonymous-inner-classes-why-is-final-keywo">Java local variable visibility in anonymous inner classes - why is ‘final’ keyword required?</a>  </p>
</blockquote>



<p>I have this function that creates some buttons. I'm trying to out.println <em>item</em> in the <em>doAction</em> method.</p>

<pre><code>    for (int i = 0; i &lt; itemsList.size(); i++) {
        String item = itemsList.get(i);
        TButton button = new TButton("" + item, 8, 415 + (25 * i), 90, 25) {
            public void doAction() {
                System.out.println("" + item);
            }
        };
        this.framework.add(button);
    }
</code></pre>

<p>I'm getting the error </p>

<pre><code>local variable item is accessed from within inner class
</code></pre>

<p>How do I do this the right way?</p>
