UnaryOperator is a Function on a single operand that produces a result of the same type as its operand.

It Transforms the input value to a result of same type.

UnaryOperator Methods

UnaryOperator extends from Function. So, it inherits the Function interface methods apply(), andThen() and compose().

It also adds a static method identity() that returns a unary operator that always returns its input argument.

Example 1 :

Output :


Example 2 : UnaryOperator using Method Reference

Output :


© 2017, www.topjavatutorial.com. All rights reserved. On republishing this post, you must provide link to original post

Leave a Reply.. code can be added in <code> </code> tags