title: What is the difference between addActionListener(this) and addActionListener(new ActionListener)?
body: <p>I want to add event handling to buttons- and I noticed that there are two ways to do this. </p>
  
  <ol>
  <li>Implement the ActionListener interface and then append event listeners to the buttons.</li>
  </ol>
  
  <p>Example:</p>
  
  <pre><code>countButton.addActionListener(this);
  </code></pre>
  
  <p>And the in the ActionPerformed method will run to display the result. </p>
  
  <ol>
  <li><p>Do not implement the ActionListener interface and instead do this: </p>
  
  <pre><code>countButton.addActionListener(new ActionListener() {
  
      public void actionPerformed(ActionEvent e)
      {
          //Execute when button is pressed
          System.out.println("You clicked the button");
      }
  });  
  </code></pre></li>
  </ol>
  
  <p>How does the second method work exactly?????!!!</p>
  
  <p>Thanks!</p>