Unary operators need only one operand to perform the task or operation.
From Java definition
Represents an operation on 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 the result are of the same type.
Here are some test cases.
@Test
public void testUnaryOperator()
{
//when
UnaryOperator<Integer> increment = (n) -> ++n;
//verify
Assertions.assertEquals(Integer.valueOf(2), increment.apply(1));
}
No comments:
Post a Comment