title: How to apply Filtering on groupBy in java streams
body: <p>How do you group first and then apply filtering using Java streams?</p>
  
  <p><strong>Example</strong>: Consider this <code>Employee</code> class: 
  I want to group by Department with a list of an employee having a salary greater than 2000.</p>
  
  <pre><code>public class Employee {
      private String department;
      private Integer salary;
      private String name;
  
      //getter and setter
  
      public Employee(String department, Integer salary, String name) {
          this.department = department;
          this.salary = salary;
          this.name = name;
      }
  }   
  </code></pre>
  
  <p>This is how I can do this </p>
  
  <pre><code>List&lt;Employee&gt; list   = new ArrayList&lt;&gt;();
  list.add(new Employee("A", 5000, "A1"));
  list.add(new Employee("B", 1000, "B1"));
  list.add(new Employee("C", 6000, "C1"));
  list.add(new Employee("C", 7000, "C2"));
  
  Map&lt;String, List&lt;Employee&gt;&gt; collect = list.stream()
      .filter(e -&gt; e.getSalary() &gt; 2000)
      .collect(Collectors.groupingBy(Employee::getDepartment));  
  </code></pre>
  
  <p><strong>Output</strong> </p>
  
  <pre><code>{A=[Employee [department=A, salary=5000, name=A1]],
   C=[Employee [department=C, salary=6000, name=C1], Employee [department=C, salary=7000, name=C2]]}
  </code></pre>
  
  <p>As there are no employees in Department B with a salary greater than 2000. So there is no key for Department B: 
  <strong>But actually, I want to have that key with empty list –</strong></p>
  
  <p><strong>Expected output</strong> </p>
  
  <pre><code>{A=[Employee [department=A, salary=5000, name=A1]],
   B=[],
   C=[Employee [department=C, salary=6000, name=C1], Employee [department=C, salary=7000, name=C2]]}
  </code></pre>
  
  <p><strong>How can we do  this?</strong></p>