Arithmetic Operators:
Given table shows all the Arithmetic operator supported by Java Language. Lets suppose variable a
hold 20 and b hold 5.
Operator Example (int a=20, b=5) Result
+ a+b 25
- a-b 20
* a*b 100
/ a/b 4
% a%b 0
Relational Operators:
Which can be used to check the Condition, it always return true or false. Lets suppose variable a hold
20 and b hold 5.
Operators Example (int a=20, b=5) Result
> a>b 1
>= a >= b 1
< a>b 0
<= a<=b 0
== a== b 0
!= a != b 1
Logical Operator:
Which can be used to combine more than one Condition?. Suppose you want to combined two
conditions a<b and b>c, then you need to use Logical Operator like (a<b) && (b>c). Here && is
Logical Operator.
Operator Example (int a=20, b=10, v=5) Result
&& (a>b) && (b>c) 1
|| (b!=c) || (a==b) 1
! !(b >= c) 0
Assignment operators:
Which can be used to assign a value to a variable. Lets suppose variable a hold 50 and b hold 30.
Operator Example (int a=50, b=30) Result
+= a+=b or a=a+b 80
-= a-=b or a=a-b 50
*= a*=b or a=a*b 1500
/= a/=b or a=a/b 50
%= a%=b or a=a%b 0