title: Convert an loop (while and for) to stream
body: <p>I have started working with Java 8 and trying to convert some loops and old syntax in my code to lambdas and streams.</p>
  
  <p>So for example, I'm trying to convert this while and for loop to stream, but I'm not getting it right:</p>
  
  <pre><code>List&lt;String&gt; list = new ArrayList&lt;&gt;();
  if (!oldList.isEmpty()) {// old is a List&lt;String&gt;
      Iterator&lt;String&gt; itr = oldList.iterator();
      while (itr.hasNext()) {
          String line = (String) itr.next();
          for (Map.Entry&lt;String, String&gt; entry : map.entrySet()) {
              if (line.startsWith(entry.getKey())) {
           String newline = line.replace(entry.getKey(),entry.getValue());
                  list.add(newline);
              }
          }
      }
  }
  </code></pre>
  
  <p>I wanted to know if it's possible to convert the above example to a single stream where there is a while loop inside of a for loop.</p>