In a stream of a list of Integer like this list.stream().max((a,b)->a+b).get();
i can only retrieve the highest value, i wanted to retrieve the position in the list of the highest value, how can i do it ?
Asked
Active
Viewed 51 times
0

Tagir Valeev
- 97,161
- 19
- 222
- 334

T4l0n
- 595
- 1
- 8
- 25
-
1A `Stream` does not record any kind of index; you can do this via a hack, but really a good old fashioned for loop walking according to indices is your best bet here. Also, the argument to your .max() is really bizarre; what is it that you want to do? – fge Feb 15 '16 at 15:16
-
Just look at http://stackoverflow.com/questions/31116190/java-8-find-index-of-minimum-value-from-a-list – J. Su. Feb 15 '16 at 15:17
-
Yes i got it how to do that without stream, just as a curiosity, doesn't the lambda in max, just iterate through the values and check the max, if not how am i supposed to write that ? – T4l0n Feb 15 '16 at 15:31