I am looking for a clean and simple way to iterate over two ArrayLists that are related directly in that each index of one maps to the index of another (in relationship).
Currently, I'm doing it via a simple for loop and I tried looking into lambdas and for-each loops but don't see a way to apply it to two lists at the same time that are of the same size.
firstList: ["Blue", "Red", "Green"]
secondList: ["Sky", "Roses", "Grass"]
for(int i = 0; i < firstList.size(); i++){
System.out.println(firstList.get(i) + " " + secondList.get(i));
}
Result:
Blue Sky
Red Roses
Green Grass
Is there a way to effectively iterate over both lists simultaneously using a lambda or a for-each loop to avoid using a for loop?