I need to create a map from primitive array of integers where key is index and value is element by current index. How can i do it using a Java Stream API?
I'm trying to do something like this but it doesn't work out for me.
IntStream.range(0, nums.length)
.collect(Collectors.toMap(i -> i, i -> nums[i]));