title: Java Action Listener not working with array
body: <p>What is wrong with this code? I am trying to have it go to the next sorted array named bk when I click on the button.</p>
  
  <pre><code>Book[] bk = new Book[5];
  bk = sortArray(bk);
  final JTextArea textArea = new JTextArea();
  
  JButton btnNext = new JButton("Next");
  btnNext.addActionListener(new ActionListener()
  {
      public void actionPerformed(ActionEvent e)
      {
          for (int i = 0; i &lt; bk.length; i++)
              textArea.append("\n" + bk[i+1]);
      }});
  </code></pre>
  
  <p>But if I declare it as final the line that sorts it tells me to take the final declaration out.</p>
  
  <p>Here the error with the final declaration:</p>
  
  <pre><code>Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
  The final local variable bk cannot be assigned. It must be blank and not using a compound assignment
  </code></pre>
  
  <p>And w/o the final declaration:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems: 
  Cannot refer to a non-final variable bk inside an inner class defined in a different method
  Cannot refer to a non-final variable bk inside an inner class defined in a different method
  </code></pre>
  
  <p>What can I do to fix this problem?</p>