Variable visibility inside anonymous class method
<p>I have a problem with XMLTool java library. Let's consider following code:</p>

<pre><code>private void parse() {
    List&lt;String&gt; list = new ArrayList&lt;String&gt;();

    doc.gotoChild("Body")
       .gotoChild("ExternalListOfCodes")
       .forEachChild(new CallBack() {

            public void execute(XMLTag doc) {
                if (doc.getCurrentTagName().equalsIgnoreCase("UnitOfMeasure")){
                    //Here's the problem!                
                    list.add(
                        doc.gotoChild("UnitOfMeasureCode").getInnerText()
                    );
                }
            }
        }
}
</code></pre>

<p>There's a loop <code>forEachChild</code> and what I'd like to achieve is to add tag content to a list. Certainly, it's not possible because variable <code>list</code> is not visible there. </p>

<p>Any ideas how to solve it? Thanks for any help!</p>
