- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Unary Operator Examples
The unary operator works on a single operand. Following are the examples of unary operators supported in java. Assume A = 60 and B = 20.
Operator | Description | Example |
---|---|---|
~ (bitwise compliment) | Binary One's Complement Operator is unary and has the effect of 'flipping' bits. | (~A ) will give -61 which is 1100 0011 in 2's complement form due to a signed binary number. |
++ (Increment) | Increases the value of operand by 1. | B++ gives 21 |
-- (Decrement) | Decreases the value of operand by 1. | B-- gives 19 |
- Related Articles
- Unary operator in C++
- Overloading unary operator in C++?
- Java Arithmetic Operator Examples
- Java Shift Operator Examples
- Java AND Operator Examples
- Java OR Operator Examples
- Java Ternary Operator Examples
- Java Assignment Operator Examples
- Overload unary minus operator in C++?
- What is Unary Negation Operator (-) in JavaScript?
- What is Unary Plus Operator in JavaScript?
- What is overloading a unary operator in C++?
- What are the unary operators in Java?
- Unary or Recursive Relationship
- Unary operators in C++

Advertisements