title: Java Anonymous Class with Interface
body: <p>I didn't write Java for a long time and need some help with something (maybe) simple.</p>
  <p>So I got this <code>Class</code> in which an <code>Interface</code> is declared :</p>
  <pre><code>public class test(){
     
  interface Checker(){
   public check();
  }
  
  public someFunction(List param1, Checker param2){
     //[do something here]
  }
  ...
  
  
  public static void main (...){
  
     someFunction(List param1, new Checker(){
            ...
            //[implementation of interface]
            ...
        });
   }
  </code></pre>
  <p>So my problem is, that (and the actual Code works fine)</p>
  <ol>
  <li><p>I really don't get <strong>why</strong> the method <code>someFunction();</code> expects a <code>Interface</code> as a parameter</p>
  </li>
  <li><p>I also don't understand <strong>why</strong> I can pass an instance of an interface to that function<code>(in</code>main()<code>). The second argument that I'm passing the </code>someFunction();`, is an instance of an interface, right?
  Well, what i was thinking of, is that it actually is some kind of anonymous class and therefore it might be possible.</p>
  </li>
  </ol>
  <p>But as I said, it's been a while since I wrote java code, and I didn't find an answer yet, so I would be really grateful if somebody could explain to me why and how this piece of code is working.</p>