I don't know the exact name for it (I'm guessing method-reference) but here is what I'm talking about. Let's say I want to take the square root of all doubles in a double array. Then, if the array is called arr, I can do this:
Arrays.stream(arr).map(Math::sqrt). // ... box it and stuff
However, if I want to square each number in an int array, I'm thinking of using Math.pow(num, 2) as the method. However, Math.pow has a second parameter, but I know it will always be 2. So I'm thinking I can do something like this:
Arrays.stream(arr).map(Math::pow(2)). // ... box it and stuff
But this results in an error. What can I do?
.mapToDouble(n -> Math.pow(n, 2))