The unary plus operator performs an automatic conversion to int when the type of its operand is byte, char, or short. This is called unary numeric promotion, and it enables you to do things like the following:

char c = 'c';
int i = +c;

Granted, it's of limited use. But it does have a purpose. See the specification, specifically sections §15.15.3 and §5.6.1.

Answer from John Feminella on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-unary-operator-with-examples
Java Unary Operator with Examples - GeeksforGeeks
July 12, 2025 - This unary operator returns the one’s complement representation of the input value or operand, i.e, with all bits inverted, which means it makes every 0 to 1, and every 1 to 0. ... a = 5 [0101 in Binary] result = ~5 This performs a bitwise complement of 5 ~0101 = 1010 = 10 (in decimal) Then the compiler will give 2’s complement of that number. 2’s complement of 10 will be -6. result = -6 ... // Java program to Illustrate Unary // Bitwise Complement Operator // Importing required classes import java.io.*; // Main class class GFG { // Main driver method public static void main(String[] arg
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › function › UnaryOperator.html
UnaryOperator (Java Platform SE 8 )
October 20, 2025 - 8 ... This is a functional interface ... @FunctionalInterface public interface UnaryOperator<T> extends Function<T,T> Represents an operation on a single operand that produces a result of the same type as its operand....
People also ask

Can unary operators be applied to all data types in Java
divYes unary operators can be applied to various data types including numeric types Boolean and objectsdiv
🌐
scholarhat.com
scholarhat.com › home
Unary operator in Java
How does the logical complement operator work
divThe logical complement operator inverts the value of a Boolean expression If the operand is true the result is false and vice versadiv
🌐
scholarhat.com
scholarhat.com › home
Unary operator in Java
What is the difference between preincrement and postincrement operators
divThe preincrement operator variable increments the variables value before its value is used while the postincrement operator variable uses the current value of the variable before incrementing itdiv
🌐
scholarhat.com
scholarhat.com › home
Unary operator in Java
🌐
ScholarHat
scholarhat.com › home
Unary operator in Java
September 5, 2025 - Here, the "unary_operator" is the unary operator being applied, and the "operand" is the value on which the operation is performed. Read More - Top 50 Java Interview Questions For Freshers
🌐
Tutorialspoint
tutorialspoint.com › java › java_unary_operators.htm
Unary Operators in Java
Java unary operators need only one operand to perform any operation, and these operators modify the value of a variable based on the operation performed. These operators include increasing a value by 1, decreasing a value by 1, and negating ...
🌐
Oracle
docs.oracle.com › javase › tutorial › java › nutsandbolts › op1.html
Assignment, Arithmetic, and Unary Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)
If you are just performing a simple increment/decrement, it doesn't really matter which version you choose. But if you use this operator in part of a larger expression, the one that you choose may make a significant difference. The following program, PrePostDemo, illustrates the prefix/postfix unary increment operator:
🌐
Scaler
scaler.com › home › topics › what are unary operators in java?
What are Unary Operators in Java? - Scaler Topics
April 8, 2024 - Note: Both i += 1 and i++ evaluate the same result but the only difference between them is that i++ uses the increment operator(unary operator) while i+=1 uses the assignment operator. Decrement operator in java is used to decrement the value of operand by one(1).
Find elsewhere
🌐
CodeGym
codegym.cc › java blog › java numbers › increment and decrement unary operators in java
Increment and Decrement Unary Operators in Java
The increment (++) operator (also known as increment unary operator) in Java is used to increase the value of a variable by 1.
Published   December 5, 2024
🌐
Vinothqaacademy
vinothqaacademy.com › docs › what-is-unary-operators-in-java
What is Unary Operators in Java? – Vinoth Tech Solutions
Unary operators in Java are powerful tools for performing basic operations on single operands, such as changing signs, incrementing/decrementing values, or inverting booleans.
🌐
BeginnersBook -
beginnersbook.com › home › java › unary operators in java with examples
Unary Operators in Java with Examples
October 15, 2022 - As the name suggests, The Unary operators in Java involve single operand. Java supports following unary operators: Unary minus(-)Increment(++)Decrement(- -)NOT(!)Bitwise Complement(~) 1. Unary minus(-) Operator Example The unary minus operator changes the sign of the operand.
🌐
PW Skills
pwskills.com › blog › java developer › unary operators in java and its types
Unary Operators In Java And Its Types
November 4, 2025 - For performing any calculations, unary operators require only one operand to perform any operations like increment, decrement, negation, etc. It consists of various operators that support working on a single operand.
🌐
GeeksforGeeks
geeksforgeeks.org › java › unaryoperator-interface-in-java
UnaryOperator Interface in Java - GeeksforGeeks
July 11, 2025 - The returned UnaryOperator does not perform any operation on its only value. Syntax: static UnaryOperator identity() Parameters: This method does not take in any parameter. Returns: A UnaryOperator which takes in one value and returns it. Below is the code to illustrate accept() method: Program 1: ... import java.util.function.UnaryOperator; public class GFG { public static void main(String args[]) { // Instantiate the UnaryOperator interface UnaryOperator<Boolean> op = UnaryOperator.identity(); // Apply identify() method System.out.println(op.apply(true)); } }
🌐
Javatpoint
javatpoint.com › unary-operators-in-java
Unary Operators in Java - Javatpoint
Unary Operators in Java with java tutorial, features, history, variables, object, programs, operators, oops concept, array, string, map, math, methods, examples etc.
🌐
Scientech Easy
scientecheasy.com › home › blog › unary operator in java
Unary Operator in Java - Scientech Easy
April 4, 2025 - Learn three types of unary operators in Java: unary minus, increment, decrement operator, pre increment, post increment, pre, post decrement
🌐
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › util › function › UnaryOperator.html
UnaryOperator (Java SE 11 & JDK 11 )
January 20, 2026 - This is a specialization of Function for the case where the operand and result are of the same type. This is a functional interface whose functional method is Function.apply(Object). ... Returns a unary operator that always returns its input argument.
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › An-example-of-UnaryOperator-in-functional-Lambda-expressions
Java's UnaryOperator in Lambda expressions example
We will use generics in the class declaration, <String>, to indicate this UnaryOpeartor’s apply method works exclusively on String objects, but this UnaryOperator interface is certainly not limited to just the text based data. You can genericize the interface with any valid Java class.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › java tutorial › unary operators in java
Unary Operators in Java | Top 5 Various Types of Unary Operators in Java
June 13, 2023 - Code Interpretations: We have demonstrated plus and minus unary operators in the above example. We have our class, then the main class within, and we have declared a simple integer with a value of 6. Then we assigned the num to the Unary Plus operator. And we later printed the result, which will be simple plain 6.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Medium
samedesilva.medium.com › an-easy-way-to-understand-unaryoperator-functional-interface-in-java8-32c32f1d0211
An easy way to understand UnaryOperator functional Interface in Java8. | by Sameera De Silva | Medium
February 7, 2024 - It represents a function that takes one argument and returns a result of the same type. It’s particularly useful when the input and output types are the same. It extends the Function interface, which is a functional interface representing ...
🌐
Baeldung
baeldung.com › home › java › core java › a guide to increment and decrement unary operators in java
A Guide to Increment and Decrement Unary Operators in Java | Baeldung
February 17, 2025 - In Java, the increment unary operator increases the value of the variable by one while the decrement unary operator decreases the value of the variable by one.