Binary Operators in Java
Binary Operators in Java
Given table shows all the Arithmetic operator supported by Java Language. Lets suppose variable a
hold 20 and b hold 5.
+ 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.
> 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.
|| (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.
+= a+=b or a=a+b 80
-= a-=b or a=a-b 50
/= a/=b or a=a/b 50
%= a%=b or a=a%b 0