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