title: Why do we use the "new" keyword with an Interface in Java?
body: <p>I'm new to Android. I've studied in basic Object Oriented Programming courses that interfaces provide a way for classes to enhance their functionality. Classes who actually enhance their functionality this way, implement those interfaces and override all the methods written in interfaces.</p>
  
  <p>Following code does the same job in Android:</p>
  
  <pre><code>public class MyActivity extends Activity implements OnClickListener {
     // All other code you may expect
  
     myButton.setOnClickListener(this);
  
     @override
     public onClick(View view) {
        // Code when view is clicked
     }
  } 
  </code></pre>
  
  <p>This code is understandable. But the following code makes no sense to me, I've searched it over different places but not getting a satisfied answer.</p>
  
  <pre><code>public class MyActivity extends Activity {
     // All other code you may expect
  
     myButton.setOnClickListener(new OnClickListner() {
  
        @override
        public onClick(View view) {
           // Code when view is clicked
        }
    });
  }
  </code></pre>
  
  <p>Now, <code>OnClickListener()</code> is an interface as said in Android documentation, and, now we are instantiating an interface. Not interfaces are implemented only? Please help me understand this point. </p>