0% found this document useful (0 votes)
4 views

Operators in JAVA

The document provides an overview of various operators in Java, categorizing them into Unary, Arithmetic, Relational, Logical, Ternary, Assignment, and Bitwise operators. Each category includes specific operators along with their descriptions and functionalities. It highlights the usage of these operators in performing different operations within Java programming.

Uploaded by

skdhakhil9
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Operators in JAVA

The document provides an overview of various operators in Java, categorizing them into Unary, Arithmetic, Relational, Logical, Ternary, Assignment, and Bitwise operators. Each category includes specific operators along with their descriptions and functionalities. It highlights the usage of these operators in performing different operations within Java programming.

Uploaded by

skdhakhil9
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Operators in JAVA:

Operators are the symbols used to perform specific operations.


Various operators can be used for different purposes.

The operators are categorized as:


Unary
Arithmetic
Relational
Logical
Ternary
Assignment
Bitwise

Unary Operators
operator Name Description
++ Post increment Increments the value after u
Pre increment Increments the value before
-- Post increment decrements the value after u
Pre increment decrements the value before
~ Bitwise complement Flips bits of the value
! Logical negation Inverts the value of a Boole

Arithmetic Operators
Operator Description

+ Additive operator (also used for string con

- Subtractive operator

* Multiplication operator

/ Division operator

% Modulus operator

Relational operators:

Operator Description
== Equal to
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
!= Not equal to

Logical Operators
Operator Name Description
&& AND The result will be true only if both expres
|| OR The result will be true if any one of the ex
The result will be false if the expression is
! NOT
a

Ternary Operator
The ternary operator is used as a single-line
replacement for if-then-else statements and acts upon
three operands.

Syntax:

<condition> ? <value if condition is true> : < value if condition is


false>

Assignment Operators
Oper
Description
ator
= Assigns the value on the right to the variable on the left

Adds the current value of the variable on the left to the value on
+=
signs the result to the variable on the left

Subtracts the value of the variable on the right from the current v
-=
on left and then assigns the result to the variable on the left

Multiplies the current value of the variable on left to the value on


*=
ssigns the result to the variable on the left
Divides the current value of the variable on left by the value on t
/=
ign the result to the variable on the left

Bitwise Operators:

Bitwise AND (&)


Bitwise OR (|)
Bitwise Exclusive OR (^)
Left shift operator (<<)
Right shift operator (>>)

You might also like