title: How to exit from forEach if some condition matches in java 8
body: <p>Can somebody let me know how to exit from forEach loop if some condition matches.I am using parallel stream.</p>
  
  <p>Below is my code.</p>
  
  <pre><code>Map&lt;int[], String[]&gt; indexAndColNamePairs = depMapEntry.getKey();
  Set&lt;List&lt;String&gt;&gt; dataRecords = depMapEntry.getValue();
  
  for(Map.Entry&lt;int[], String[]&gt; indexAndColNamePair: indexAndColNamePairs.entrySet())
  {
      int refColIndex = indexAndColNamePair.getKey()[0];
      Stream&lt;List&lt;String&gt;&gt; dataRecs = dataRecords.parallelStream();
      dataRecs.forEach((row) -&gt; {
          if(referencingValue.equals(row.get(refColIndex)))
          {
              requiredColValueAndName.put(row.get(indexAndColNamePair.getKey()[1]),
                  indexAndColNamePair.getValue()[1]);
          }
  }); 
  </code></pre>
  
  <p><code>if(referencingValue.equals(row.get(refColIndex)))</code> then i am inserting value to map and then i need to exit.</p>