title: Return a predicate as a lambda in Java
body: <p>In <a href="http://www.dreamsyssoft.com/java-8-lambda-tutorial/filter-tutorial.php" rel="noreferrer">this</a> online tutorial they use a lambda to filter a list of users:</p>
  
  <pre><code>List&lt;User&gt; olderUsers = users.stream().filter(u -&gt; u.age &gt; 30).collect(Collectors.toList());
  </code></pre>
  
  <p>Now I want to make a function which accepts a lambda (the <code>u -&gt; u.age &gt; 30</code> part) so that I can put any criterion I want inside a this lambda. But I'm a bit stuck on how to implement this. I have made an empty interface <code>Filter</code> and I made the following methods:</p>
  
  <pre><code>public List&lt;User&gt; filterUsers(Filter f, List&lt;User users&gt;){
      return users.stream().filter(f).collect(Collectors.toList());
  }
  public Filter olderThan(int age) {
      return u -&gt; u.getAge() &gt; age;
  }
  </code></pre>
  
  <p>But this gives a number of errors.</p>
  
  <p>(I made a getter of the <code>age</code>field in <code>user</code>).
  Is there a way to adjust the interface <code>Filter</code> or the other methods to make this work?</p>