UnaryOperator identity returns a unary operator that always returns its input argument.
identity
has the following syntax.
static <T> UnaryOperator<T> identity()
The following example shows how to use identity
.
import java.util.function.UnaryOperator; /* w w w. j a v a 2s .co m*/ public class Main { public static void main(String[] args) { UnaryOperator<String> i = (x)-> x.toUpperCase(); System.out.println(i.apply("java2s.com")); } }
The code above generates the following result.