Friday, May 31, 2013

Operators in JAVA




Operators are the thing which operates on variable to produce results. They manipulate both the data and variables. JAVA provides wide variety of operators. Those are as follows:-

1)      Arithmetic Operators:-
These operators are used on mathematical expressions. These operators are as follows:-

Sr. No.
Operator
Meaning
Sample Program
1
+
Addition
2
-
Subtraction
3
*
Multiplication
4
/
Division
5
%
Modulus
6
+=
Addition Assignment
7
-=
Subtraction Assignment
8
*=
Multiplication Assignment
9
/=
Division Assignment
10
%=
Modulus Assignment
11
++
Increment
12
--
Decrement

2)      Bitwise Operators:-
These operators are operated on type int, long, short, char and byte. These operators operate on individual bit of operand. These operators are as follows:-

Sr. No.
Operator
Meaning
Sample Program
1
~
Bitwise NOT
2
&
Bitwise AND
Click HERE
3
|
Bitwise OR
Click HERE
4
^
Bitwise EXCLUSIVE OR (XOR)
Click HERE
5
&=
Bitwise AND Assignment
Click HERE
6
|=
Bitwise OR Assignment
Click HERE
7
^=
Bitwise EXCLUSIVE OR (XOR) Assignment
Click HERE
8
>> 
Shift right
Click HERE
9
>>> 
Shift right zero fill
Click HERE
10
>>=
Shift right Assignment
Click HERE
11
>>>=
Shift right zero fill Assignment
Click HERE
12
<< 
Shift left
Click HERE
13
<<=
Shift left Assignment
Click HERE

3)      Relational Operators:-
These operators used to decide the relation between the operands. These operators are as follows:-

Sr. No.
Operator
Meaning
Sample Program
1
==
Equal to
Click HERE
2
!=
Not equal to
Click HERE
3
> 
Greater than
Click HERE
4
>=
Greater than or equal to
Click HERE
5
< 
Less than
Click HERE
6
<=
Less than or equal to
Click HERE


4)      Logical Operators:-
Logical operators are used to combine operands. These operators are as follows:-

Sr. No.
Operator
Meaning
Sample Program
1
&&
Logical AND
Click HERE
2
||
Logical OR
Click HERE
3
!
Logical NOT
Click HERE
4
^
Logical XOR
Click HERE
5
?:
Ternary if - else
Click HERE

5)      Assignment Operators:-
These operators are used to assign a particular value to the operator or to check the value of particular operand.


Sr. No.
Operator
Meaning
Sample Program
1
=
Assign the value
Click HERE
2
==
Check the value
Click HERE
3
===
Check the value with case sensitive
Click HERE


0 comments:

Post a Comment

    Translate

    Protected by Copyscape