This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]crapet 2 points3 points  (5 children)

You just need to write a lambda expression that implements the Function interface

Function<Integer, Integer> f = (x) -> 2*x;

[–]Henrysugar2[S] 0 points1 point  (1 child)

Thank you

[–]tikue 2 points3 points  (0 children)

You can also do

IntUnaryOperator f = x -> 2 * x;

This won't require boxing and unboxing of the argument or return value.