title: Java: Create a simple generic method to count after applying filter
body: <p>I want to create a simple generic method to count the <code>numbers</code> after applying the filter based on the provided <code>predicate</code>. </p>
  
  <pre><code>static int count(Collection &lt; ? extends Number &gt; numbers, Predicate &lt; ? extends Number &gt; predicate) {
    return numbers.stream().filter(predicate).count();
  }
  </code></pre>
  
  <p>It gives me the following error:</p>
  
  <blockquote>
    <p>incompatible types: Predicate cannot be converted to <code>Predicate&lt;? super CAP#2&gt;</code>
    where CAP#1, CAP#2 are fresh type-variables:</p>
    
    <p>CAP#1 extends Number from capture of ? extends Number</p>
    
    <p>CAP#2 extends Number from capture of ? extends Number</p>
  </blockquote>