Get Index while iterating list with stream [duplicate]
问题 This question already has answers here : Is there a concise way to iterate over a stream with indices in Java 8? (22 answers) Closed 2 years ago . List<Rate> rateList = guestList.stream() .map(guest -> buildRate(ageRate, guestRate, guest)) .collect(Collectors.toList()); class Rate { protected int index; protected AgeRate ageRate; protected GuestRate guestRate; protected int age; } In the above code, is it possible to pass index of guestList inside buildRate method. I need to pass index also