title: How to iterate ListObjectOne over the ListObjectTwo usring stream Java 8
body: <p>I have two different lists the first one is list and the second one is List
  List studentList = new ArrayList&lt;&gt;();
  List moduleList = new ArrayList&lt;&gt;();</p>
  <p>How can I iterate the modulList over studentList so that you can see which student has passed for which Module;</p>
  <p><a href="https://i.stack.imgur.com/tsX2F.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>class Student {</p>
  <pre><code>private String studentId;
  private String name;
  private Type gender;
  private String studClass;
  private String education;
  private HashMap&lt;String, Module&gt; faillOrPass;
  
  public Student()
  {
      faillOrPass = new HashMap&lt;String, Module&gt;();
  }
  
  public Student (String studentId, String name, Type gender, String studClass, String education)
  {
      faillOrPass = new HashMap&lt;String, Module&gt;();
      setStudentId(studentId);
      setName(name);
      setGender(gender);
      setStudClass(studClass);
      setEducation(education);
  }
  
  public enum Type { MALE, FAML}
  
  // getters and setters
  // equals() and hashCode()
  // toString()
  </code></pre>
  <p>}</p>
  <p>class Module {</p>
  <pre><code>String modulecode;
  int grade;
  int year;
  
  public Module(String code, int year) {
      setModule(code);
      setYear(year);
      setGrade(-1);
  }
  
  // getters and setters
  // equals and hashCode
  // toString
  </code></pre>
  <p>}
  public class TestClass {</p>
  <pre><code>final static Student st = new Student();
  static String ZAYNUL = st.setVolledigeNaam(&quot;Zaynul Zaini&quot;);
  static String PIPO = st.setVolledigeNaam(&quot;Pipo&quot;);
  static String SANNY = st.setVolledigeNaam(&quot;Sanny Saniwich&quot;);
  static String JOHAN = st.setVolledigeNaam(&quot;Johan Ginger&quot;);
  static String DURSAH = st.setVolledigeNaam(&quot;Dursah Pikobillo&quot;);
  static String ROMAN = st.setVolledigeNaam(&quot;Roman Romanawich&quot;);
  static String TOM = st.setVolledigeNaam(&quot;Johonson&quot;);
  static String ANDRE = st.setVolledigeNaam(&quot;Andersons&quot;);
  
  public static List&lt;Vak&gt; getModuleList() {
      return List.of(
  
              new Vak(ZAYNUL, &quot;IT&quot;, 8, 2020),
              new Vak(SANNY, &quot;IT&quot;, 10, 2019),
              new Vak(ROMAN, &quot;IT&quot;, 9, 2018),
              new Vak(MALIKA, &quot;IT&quot;, 8, 2017),
              new Vak(DURSAH,&quot;IT&quot;, 10, 2016),
              new Vak(PIPO,&quot;IT&quot;, 10, 2020),
  
              new Vak(PIPO,&quot;IPC&quot;, 5, 2020),
              new Vak(ZAYNUL,&quot;IPC&quot;, 6, 2019),
              new Vak(SANNY,&quot;IPC&quot;, 4, 2018),
              new Vak(ROMAN,&quot;IPC&quot;, 1, 2017),
              new Vak(MALIKA,&quot;IPC&quot;, 5, 2016),
              new Vak(DURSAH,&quot;IPC&quot;, 4, 2020));
  }
  
  public static List&lt;Student&gt; getStudentList() {
      List&lt;Student&gt; listVak = new ArrayList&lt;&gt;();
      listVak.add(new Student(&quot;011&quot;, ZAYNUL, Student.Type.MALE, &quot;first year&quot;, &quot;Architecture&quot;));
      listVak.add(new Student(&quot;012&quot;, MALIKA, Student.Type.FEMALE, &quot;second year&quot;, &quot;economics&quot;));
      listVak.add(new Student(&quot;013&quot;, SANNY, Student.Type.FEMALE, &quot;third year&quot;, &quot;IT&quot;));
      listVak.add(new Student(&quot;014&quot;, ROMAN, Student.Type.MALE, &quot;fourth year&quot;, &quot;Astronomy&quot;));
      listVak.add(new Student(&quot;015&quot;, TOM, Student.Type.MALE, &quot;second year&quot;, &quot;economics&quot;));
      listVak.add(new Student(&quot;016&quot;, ANDRE, Student.Type.FEMALE, &quot;third year&quot;, &quot;IT&quot;));
      listVak.add(new Student(&quot;017&quot;, JOHAN, Student.Type.MALE, &quot;fourth year&quot;, &quot;Astronomy&quot;));
      return listVak;
  }
  
  public static void  getPassedAndFaillModule(List&lt;Student&gt; listSt, List&lt;Module&gt; listVak) {
  
      List&lt;Student&gt; filteredList = listSt.stream()
              .filter(student -&gt; listVak.stream()
                      .filter(md -&gt; md.getCijfer() &gt; 5)
                      .anyMatch(mdo -&gt; mdo.getStudentName() !=null
                              &amp;&amp; student.getVolledigeNaam().equals(mdo.getStudentName())))
              .collect(Collectors.toList());
      filteredList.forEach(x -&gt; System.out.println(x));
  
  }
  
  public static void main(String[] args) {
      System.out.println(&quot;Print the result: &quot;);
      getPassedAndFaillModule(getStudentList(), getModuleList());
  }
  </code></pre>
  <p>}</p>
  <p>This is the result which I get but is not good.</p>
  <p>Print the result:
  StudentImpl{studentnummer='011', volledigeNaam='Zaynul Zaini', type='MALE', klaas='first year', studierichting='Architecture', vakkenLijst={}}</p>
  <p>StudentImpl{studentnummer='012', volledigeNaam='Malika Ginger', type='FEMALE', klaas='second year', studierichting='economics', vakkenLijst={}}</p>
  <p>StudentImpl{studentnummer='013', volledigeNaam='Sanny Saniwich', type='FEMALE', klaas='third year', studierichting='IT', vakkenLijst={}}</p>
  <p>StudentImpl{studentnummer='014', volledigeNaam='Roman Romanawich', type='MALE', klaas='fourth year', studierichting='Astronomy', vakkenLijst={}}</p>