0

I have a List of Integer's as like below.

List<Integer> list = Arrays.asList(1,2,3,4,5,6);

I want something like Scala zipWithIndex() method in Scala List.

Can we do something similar with Java-8 FP?

Shankar
  • 8,529
  • 26
  • 90
  • 159
  • 3
    http://stackoverflow.com/questions/18552005/is-there-a-concise-way-to-iterate-over-a-stream-with-indices-in-java-8 – Yuval Itzchakov Sep 03 '16 at 15:29
  • 1
    See also http://stackoverflow.com/questions/17640754/zipping-streams-using-jdk8-with-lambda-java-util-stream-streams-zip There's no direct way. – Tunaki Sep 03 '16 at 15:31
  • @Tunaki : whatever you referred is zip not zipWithIndex. – Shankar Sep 03 '16 at 15:45
  • 2
    `zipWithIndex` _is_ `zip` added with a Stream of indexes. What you want is in the linked duplicate question. My comment above was a FYI, that's all. – Tunaki Sep 03 '16 at 15:46

0 Answers0