티스토리 뷰

공부

[Java] forEach with index

승가비 2020. 10. 3. 20:12
728x90
IntStream.range(0, params.size())
  .forEach(idx ->
    query.bind(
      idx,
      params.get(idx)
    )
  )
;

https://stackoverflow.com/questions/22793006/java-8-foreach-with-index

 

Java 8 forEach with index

Is there a way to build a forEach method in Java 8 that iterates with an index? Ideally I'd like something like this: params.forEach((idx, e) -> query.bind(idx, e)); The best I could do right ...

stackoverflow.com

 

728x90
댓글