title: How does the constructor for the javamail Authenticator work?
body: <p>I'm trying to write a simple Java program that just sends emails and retrieves text from emails in my inbox, and I'm a little confused about how the Authenticator object works.  Why is there bracketed code immediately after the constructor and how does it function?  I found this example code for creating a Session object, and it works fine, but I've never seen this kind of notation before and can't find any other examples of it elsewhere.</p>
  
  <pre><code>Session session = Session.getInstance(props,
    new javax.mail.Authenticator() {
       protected PasswordAuthentication getPasswordAuthentication() {
          return new PasswordAuthentication(username, password);
       }
    });
  </code></pre>