Is there a way to modify elements of a list selectively based on index using stream.
For example, I want to multiply each element of a list by 2, except element at a particular index.
I tried creating a map function, but without success. I want to write a condition that if index of element is equal to the skipIndex then I'll return the element, otherwise I'll return the elememt multiplied by 2.
int skipIndex = getSomeIndex();
list = list.stream().map(a -> {
if(){ return a;}
return a*2;
}).collect(Collectors.toList());
Thanks in advance.