title: Java 8 map each field value of a List to another similar List
body: <p>I have 2 List of objects:</p>
  
  <pre><code>List&lt;User&gt;
  List&lt;UserResource&gt;
  </code></pre>
  
  <p>For <code>User</code> class:</p>
  
  <pre><code>public class User {
  
      private int id;
  
      private String name;
  
      private String address; 
  
      **SETTERS &amp; GETTERS**
  }
  </code></pre>
  
  <p>For <code>UserResource</code> class:</p>
  
  <pre><code>public class UserResource {
  
      private String name;
  
      private String address; 
  
      **SETTERS &amp; GETTERS**
  }
  </code></pre>
  
  <p>My <code>List&lt;User&gt;</code> has data and i want to map <strong>value</strong> in <code>name</code> and <code>address</code> to <code>UserResource</code>'s <code>name</code> and <code>address</code>, using java 8 stream and lambda, but i not sure how to do it.</p>
  
  <p>Search online for quite sometime but not able to find similar question. Something like:</p>
  
  <pre><code>List&lt;User&gt; users = **data inserted**
  List&lt;UserResource&gt; resources = users.forEach(u -&gt;{
      u.setName(users.getName());
      u.setAddress(users.getAddress());
  });
  </code></pre>
  
  <p>I tried something like following, but im not using constructor, not really sure how to fix it. </p>
  
  <pre><code>List&lt;UserResource&gt; userResources = users.stream().map(u -&gt; new UserResource(u.getName(), u.getAddress())).collect(Collectors.toList());
  </code></pre>