title: How to write below code to functional way using java 8
body: <p>I am new to lambda expressions and functional programming.<br/>
  I wrote below code snippet using java 8. <br/></p>
  
  <pre><code>     List&lt;Employee&gt; myList = new ArrayList&lt;&gt;();
       Map&lt;String, List&lt;Integer&gt;&gt; mapOf = new HashMap&lt;&gt;();
       mapOf.put("key1", Arrays.asList(1, 2, 3));
  
       mapOf.put("key2", Arrays.asList(4, 5, 6));
       mapOf.put("key3", Arrays.asList(7, 8));
  
       mapOf.forEach((k ,v) -&gt; {
           Employee emp = new Employee();
           v.stream().forEach(o -&gt;{
               emp.setFirstName("John Doe");
               myList.add(emp);
               System.out.println("Posting Data for :: " + k + " :: " + o);
           });
       });
  </code></pre>
  
  <p><br/>Expected output</p>
  
  <pre><code>Posting Data for :: key1 :: 1
  Posting Data for :: key1 :: 2
  Posting Data for :: key1 :: 3
  Posting Data for :: key2 :: 4
  Posting Data for :: key2 :: 5
  Posting Data for :: key2 :: 6
  Posting Data for :: key3 :: 7
  Posting Data for :: key3 :: 8
  </code></pre>
  
  <p><br/>
  The above code is working as expected, but it's a <em>spaghetti</em> <em>code</em>.<br/>
  I read many articles stating that we should not use <strong>{</strong> <strong>}</strong> inside lambda expressions as it makes code difficult to understand. <br/>
  <br/>
  So, now I am trying to convert it into the <em>Functional</em> way.<br/>
  Please help.</p>