DEV Community

javatute673
javatute673

Posted on

How to write nested loop using Java 8 Stream

Consider we have two lists List and List. The List of Subject is defined in Student class.

or consider we have below code that we want to convert into Java 8.

List<String> list = new ArrayList();
for(int i = 0; i < 10; i++) {
    for(int j = 0; j < 10; j++) {
        if(dataMap[i][j] == 1)
            list.add(new Data(i,j));
    }
}  
Enter fullscreen mode Exit fullscreen mode

We want to convert above code into Java 8.

https://javatute.com/core-java/how-to-filter-data-from-nested-list-using-stream-java-8/

Top comments (0)