title: Java 8: HashMap initialization with lambda expressions
body: <p>I'm trying to declare and define larger hash map at once. This is how I do it:</p>
  
  <pre><code>public HashMap&lt;Integer, Callable&lt;String&gt;&gt; opcode_only = new HashMap&lt;Integer, Callable&lt;String&gt;&gt;() {{
      put(x, y);
      put(x, y);
  }};
  </code></pre>
  
  <p>But, when I try to use lambda expressions in body of <code>put</code>, I'm hitting on eclipse warrning/error. This is how I use lambda in HashMap:</p>
  
  <pre><code>public HashMap&lt;Integer, Callable&lt;String&gt;&gt; opcode_only = new HashMap&lt;Integer, Callable&lt;String&gt;&gt;() {{
      put(0, () -&gt; { return "nop"; });
      put(1, () -&gt; { return "nothing...."; });
  }};
  </code></pre>
  
  <p>Eclipse underlines whole part of lambda starting with comma before. 
  Error messages:</p>
  
  <pre><code>Syntax error on token ",", Name expected    
  Syntax error on tokens, Expression expected instead
  </code></pre>
  
  <p>Does anybody know what am I doing wrong? Is initialization by lambda expression allowed in <code>HashMap</code>? Please help.</p>