I have an integer array int[]
and would like to create an List
of entries that contains:
class Entry {
int theIndexOfNumber;
int numberInTheArray;
}
For example, for {3,5,7},
I would like to have a list of
{1, 3}, {2, 5},(3, 7}
This is easy using some Java code but I want to do it in a Java 8 way using stream.
I think I should use some sort of collector but don't know how to write this. Can someone please help?