title: java 8 creating custom object from a list of objects
body: <p>This is extension to question .I have a list of messages .I want to create a list of custom message with their audit  values.</p>
  
  <p><a href="https://stackoverflow.com/questions/43920835/list-of-id-from-a-list-of-age-using-java-8">list of id from a list of age using java 8</a></p>
  
  <pre><code>public class Messages {
  
  int id;
  String message;
  int audId;
  String audmessage;
  
  public int getId() {
      return id;
  }
  
  public void setId(int id) {
      this.id = id;
  }
  
  public String getMessage() {
      return message;
  }
  
  public void setMessage(String message) {
      this.message = message;
  }
  
  public int getAudId() {
      return audId;
  }
  
  public void setAudId(int audId) {
      this.audId = audId;
  }
  
  public String getAudmessage() {
      return audmessage;
  }
  
  public void setAudmessage(String audmessage) {
      this.audmessage = audmessage;
  }
  
  public Messages(int id, String message, int audId, String audmessage) {
  
      this.id = id;
      this.message = message;
      this.audId = audId;
      this.audmessage = audmessage;
    }
  }
  
  
  public class CustomMessage {
  
  int id;
  String msg;
  List&lt;Aud&gt; list;
  //getters and setters
   }
  
  public class Aud {
  
  int id;
  int message;
     //getters and setters
   }
  
  
    public class Demo {
  
      public static  void main(String args[]){
        List&lt;Messages&gt; list = new ArrayList&lt;Messages&gt;();
        list.add(new Messages(1,"abc",10,"a1"));
        list.add(new Messages(2,"ac",21,"a2"));
        list.add(new Messages(3,"adc",31,"a3"));
        list.add(new Messages(4,"aec",40,"a4"));
        list.add(new Messages(1,"abc",11,"a5"));
        list.add(new Messages(2,"ac",22,"a5"));
       }
  </code></pre>
  
  <p>Expected output is 1,abc->List of audits as (10,a1),(11,a5);</p>