title: Java8 Lambda compare two List and trasform to Map
body: <p>Suppose I have two class:</p>
  <pre><code>class Key {
   private Integer id;
   private String key;
  }
  
  class Value {
    private Integer id;
    private Integer key_id;
    private String value;
  }
  </code></pre>
  <p>Now I fill the first list as follows:</p>
  <pre><code>List&lt;Key&gt; keys = new ArrayLisy&lt;&gt;();
  keys.add(new Key(1, &quot;Name&quot;));
  keys.add(new Key(2, &quot;Surname&quot;));
  keys.add(new Key(3, &quot;Address&quot;));
  </code></pre>
  <p>And the second one:</p>
  <pre><code>List&lt;Value&gt; values = new ArrayLisy&lt;&gt;();
  values.add(new Value(1, 1, &quot;Mark&quot;));
  values.add(new Value(2, 3, &quot;Fifth Avenue&quot;));
  values.add(new Value(3, 2, &quot;Fischer&quot;));
  </code></pre>
  <p>Can you please tell me how can I rewrite the follow code:</p>
  <pre><code>for (Key k : keys) {
          for (Value v : values) {
              if (k.getId().equals(v.getKey_Id())) {
                  map.put(k.getKey(), v.getValue());
                  break;
          }
      }
  }
  </code></pre>
  <p>Using Lambdas?</p>
  <p>Thank you!</p>
  <p>‐------UPDATE-------</p>
  <p>Yes sure it works, I forget &quot;using Lambdas&quot; on the first post (now I added). I would like to rewrite the two nested <code>for</code> cicle with Lamdas.</p>