title: Block Statements in Java
body: <p>I have a class MyMap which extends java.util.HashMap, the following code works as a block of statements but I don't understand the use of the extra curly braces</p>
  
  <pre><code>MyMap m = new MyMap() {
    {
        put("some key", "some value");
    }
  };
  </code></pre>
  
  <p>Now why do I need the extra curly braces, can't I just do this (but this raises compile error)</p>
  
  <pre><code>MyMap m = new MyMap() {
      put("some key", "some value");
  };
  </code></pre>