I have two lists as follow
List names = Arrays.asList(\"James\",\"John\",\"Fred\");
List ages = Arrays.asList(25,35,15);
While Alexis C. answer is correct, one would argue it is the easiest way to achieve requested behavior in Java 8. I propose:
int[] i = {0};
names.forEach(name -> {
System.out.println(name + ages.get(i[0]++));
});
Or even without index:
List agesCopy = new ArrayList(ages);
names.forEach(name -> {
System.out.println(name + agesCopy.remove(0));
});