title: How do I iterate over a stream in Java using for?
body: <p>I have this code:</p>
  
  <pre><code>List&lt;String&gt; strings = Arrays.asList("a", "b", "cc");
  for (String s : strings) {
      if (s.length() == 2)
          System.out.println(s);
  }
  </code></pre>
  
  <p>I want to write it using a filter and a lambda:</p>
  
  <pre><code>for (String s : strings.stream().filter(s-&gt;s.length() == 2)) {
      System.out.println(s);
  }
  </code></pre>
  
  <p>I get <code>Can only iterate over an array or an instance of java.lang.Iterable</code>.</p>
  
  <p>I try:</p>
  
  <pre><code>for (String s : strings.stream().filter(s-&gt;s.length() == 2).iterator()) {
      System.out.println(s);
  }
  </code></pre>
  
  <p>And I get the same error. Is this even possible? I would really prefer not to do stream.forEach() and pass a consumer. </p>
  
  <p>Edit:  it's important to me not to copy the elements.</p>