title: Use of class definitions inside a method in Java
body: <p>Example:</p>
  
  <pre><code>public class TestClass {
  
      public static void main(String[] args) {
          TestClass t = new TestClass();
      }
  
      private static void testMethod() {
          abstract class TestMethod {
              int a;
              int b;
              int c;
  
              abstract void implementMe();
          }
  
          class DummyClass extends TestMethod {
              void implementMe() {}
          }
  
          DummyClass dummy = new DummyClass();
      }
  }
  </code></pre>
  
  <p>I found out that the above piece of code is perfectly legal in Java. I have the following questions.</p>
  
  <ol>
  <li>What is the use of ever having a class definition inside a method?</li>
  <li>Will a class file be generated for <code>DummyClass</code></li>
  <li>It's hard for me to imagine this concept in an Object Oriented manner. Having a class definition inside a behavior. Probably can someone tell me with equivalent real world examples.</li>
  <li>Abstract classes inside a method sounds a bit crazy to me. But no interfaces allowed. Is there any reason behind this?</li>
  </ol>