Concept name required
<p>I can't remember the name of this concept.</p>

<pre><code>  public interface MainInterface {
      public void method1();
      public void method2();
 }

  void testMethod() {
        methodMain(new MainInterface() {

            @Override
            public void method1() {
                System.out.println("This is method1");
            }

            @Override
            public void method2() {
                System.out.println("This is method2");
            }
        });
    }

   void methodMain(MainInterface mi) {
        mi.method1();
        mi.method2();
   }
</code></pre>

<ul>
<li>I create the instance of MainInterface without giving the name of object</li>
<li>I implement the interface methods</li>
<li>Then pass the instance with unknown name to methodMain.</li>
</ul>

<p>What is this concept and how exactly it works?</p>
