title: How exactly does actionListener using anonymous objects work?
body: <p>I'm kind of confused right now. I have a button let's call it
  b1</p>
  
  <p>now I want to add an actionListener so by using anonymous objects I would do this</p>
  
  <pre><code>      b1.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent ae){
                               ...
                   }
             });
  </code></pre>
  
  <p>I can't understand what an object of ActionListener represents though. Isn't ActionListener an interface? so we're creating an object of an interface? how it this possible and why are we doing this?</p>
  
  <p>when I try this code </p>
  
  <pre><code>  ActionListener al = new ActionListener();
  </code></pre>
  
  <p>it gives me an error saying</p>
  
  <pre><code>  Cannot instantiate the type ActionListener
  </code></pre>
  
  <p>if I use </p>
  
  <pre><code>   ActionListener al;
  </code></pre>
  
  <p>it's correct, but what can I do with al?</p>
  
  <p>thanks in advance</p>