title: Nested foreach with Stream API
body: <p>I have a case where A has a list of B and B has some property i need.</p>
  
  <pre><code>pseudocode structure
  class A
     List&lt;B&gt; elements;
  
  class B
     Property property;
  </code></pre>
  
  <p>I have List of A. In order, to get property i should go through the double foreach loop to get the property i want. Like this:</p>
  
  <pre><code>String myFutureProp = null;
  for (A a: list of A) {
      for(B b: list of B) {
         if("MY_PROPERTY".equals(b.getKey) {
             myFutureProp = b.getValue();   
         }
      }
  }
  </code></pre>
  
  <p>I was thinking to get it more tasty using Stream API. I was looking forward with 
  forEach() solution:</p>
  
  <pre><code>final String[] myFutureProp = {null}
      a.getElements()
                 .foreach(b -&gt; b.getElements().stream()
                        .filter("MY_PROPERTY"::equals)
                        .forEach(prop -&gt; myFutureProp[0] = (String)prop.getValue);
  </code></pre>
  
  <p>Then i'm taking myFutureProp[0] but it looks ugly to be honest. Is it any another solution in Stream API that i'm able to use? </p>