title: Java Streams: find if stream contains null
body: <p>Most probably a duplicate, however I was not able to find any particular one.</p>
  
  <h2>Given</h2>
  
  <pre><code>public static void main(String[] args) {
      System.out.println(
              Arrays.asList(null, null, 1)
                      .stream()
                      .filter(obj -&gt; obj == null)
                      .findAny()
                      .isPresent()
      );
  }
  </code></pre>
  
  <h2>Expectation</h2>
  
  <p>Should at least work (i.e return <em>false</em> because <em>findAny</em> returns <em>Optional</em>).</p>
  
  <h2>Actual</h2>
  
  <p><code>NullPointerException</code> is thrown</p>
  
  <h2>Question</h2>
  
  <p>Is it a bug or a feature?</p>
  
  <p>Thanks for your opinion and explanation.</p>