JAVA OPERATOR

Silent Killer
2 min readApr 23, 2021

--

Operators in Java can be classified into 5 types:

  1. Arithmetic Operators
  2. Assignment Operators
  3. Relational Operators
  4. Logical Operators
  5. Unary Operators
  6. Bitwise Operators

1. Java Arithmetic Operators

Arithmetic operators are used to perform arithmetic operations on variables and data. For example,

a + b;

Here, the + operator is used to add two variables a and b. Similarly, there are various other arithmetic operators in Java.

Other operator

+Addition

-Subtraction

*Multiplication

/ Division

%Modulo Operation (Remainder after division)

2. Java Assignment Operators

=

+=

-=

*=

/=

%=

3. Java Relational Operators

== Is Equal To

!= Not Equal To

> Greater Than

< Less Than

>= Greater Than or Equal To

<= Less Than or Equal To

4. Java Logical Operators

&& (Logical AND) expression1 && expression2true only if both expression1 and expression2 are true

|| (Logical OR) expression1 || expression2true if either expression1 or expression2 is true

! (Logical NOT) true if expression is false and vice versa

5. Java Unary Operators

+ Unary plus: not necessary to use since numbers are positive without using it

- Unary minus: inverts the sign of an expression

++ Increment operator: increments value by 1

-- Decrement operator: decrements value by 1

! Logical complement operator: inverts the value of a boolean

6. Java Bitwise Operators

~ Bitwise Complement

<< Left Shift

>> Right Shift

>>> Unsigned Right Shift

& Bitwise AND

^ Bitwise exclusive OR

Reference

--

--