UnaryOperator

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 :

HELLO
 

Example 2 : UnaryOperator using Method Reference

Output :

HELLO
 

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

Leave a Reply