3. OPERATORS
• Operators are the predefined symbolic instructions
which are used to perform the operations on
operands (data).
4. Like ‘C’, ‘Java’ also support 8 types of operators
1. Arithmetic Operator
2. Relational / Comparison operator
3. Logical operator
4. Assignment operator
5. Increment /Decrement operator
6. Conditional operator
7. Bitwise operator
8. Special operator
5. 1. ARITHMETIC OPERATOR
These operator are used to perform arithmetical operation.
Operator Name Symbol
Addition +
Subtraction -
Multiplication *
Division /
Modulus %
6. 2. RELATIONAL / COMPARISON OPERATOR
These operator are used to compare two operands together.
Operator name symbol
Greater than >
Greater than equal to >=
less than equal to <=
less than <
Equal to ==
Not equal to !=
7. 3. LOGICAL OPERATOR
These operator are used to combine two or more
condition together.
Operator name Symbol
AND &&
OR !!
NOT !
8. 4. ASSIGNMENT OPERATOR
Equal to sign is called assignment operator it is used
to assign some value or expression into a variable.
Assignment always take place right to left.
a=b
b=30
c=a+b
9. 5. INCREMENT/ DECREMENT OPERATOR
‘++’ is called increment operator and
‘- -’ is called decrement operator .
It is used to increase or decrease the values of variable by 1.
a++ a=a+1// postfix notation
++a a=a+1// prefix notation
b-- b=b-1//postfix
--b b=b-1//prefix
10. Postfix Operator
• int a=5, b;
b=a++ a=6
Assignment at first b=5 and then decrement.
int a=4, b;
b=a-- ; a=3
b=4
11. Prefix Operator
int a=5, b;
B=++a; a=6
b=6
increment at first and then assigned
Example:- int a=4,b;
B=--a, a=3
b=3
12. 6. CONDITIONAL OPERATOR (‘?’ , ‘:’)
‘? :’ is simultaneously called as conditional operator.
It is used to assign some value or expression into a
variable on some condition
v= (condition ? Expression 1: expression 2);
possible output 1. if true
2. true value
3. false value
4. if false
14. 7. BITWISE OPERATOR
These operator are used to perform the operation on bit values (0,1) so
these are specially used for bit level programming.
A). Bitwise logical
AND - &
OR - !
XOR - ^
B). Shift operator
left shift - <<
right shift - >>
C). Bitwise complement operator
NOT - ~ (TILDE)
15. 8. SPECIAL OPERATOR
Comma(,) and “ instance of” are called as special operator.
Comma (,); operator is not supported by java.
int a,b,c ;
use of comma
INATANCE OFF:- It is used to take whether an object belongs to
particular class or not.