UnaryOperator represents an operation on a single operand that produces a result of the same type as its operand. This is a specialization of Function for the case where the operand and result are of the same type.
The following example shows how to use UnaryOperator
.
import java.util.function.UnaryOperator; //from w w w.j a va 2 s.c o 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.