JAVA OPERATOR
Operators in Java can be classified into 5 types:
- Arithmetic Operators
- Assignment Operators
- Relational Operators
- Logical Operators
- Unary Operators
- 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