title: How to perform nested 'if' statements using Java 8/lambda?
body: <p>I have the following code and would like to implement it using lambda functions just for fun. Can it be done using the basic aggregate operations?</p>
  
  <pre><code>List&lt;Integer&gt; result = new ArrayList&lt;&gt;();
  
  for (int i = 1; i &lt;= 10; i++) {
      if (10 % i == 0) {
          result.add(i);
          if (i != 5) {
              result.add(10 / i);
          }
      }
  }
  </code></pre>
  
  <p>Using lambda:</p>
  
  <pre><code>List&lt;Integer&gt; result = IntStream.rangeClosed(1, 10)
                                  .boxed()
                                  .filter(i -&gt; 10 % i == 0)
                                  // a map or forEach function here?
                                  // .map(return 10 / i -&gt; if i != 5)
                                  .collect(Collectors.toList());
  </code></pre>