Definition of Java Operator: An operator performs a particular operation on the operands it is applied on.
Types of Operators in java:
- Assignment Operators
- Arithmetic Operators
- Unary Operators
- Equality Operators
- Relational Operators
- Conditional Operators
- instanceof Operators
- Bitwise Operators
- Shift Operators
Assignment Operator:
| Operator | Description | Example |
| = | Assignment | int i=10; int j=i; |
Arithmetic Operators:
| Operator | Description | Example |
| + | Addition | int i=8+9; byte b=(byte) 7+9; |
| - | Substraction | int i=9-3; |
| * | Multiplication | int i=7*9; |
| / | Division | int i=12/4; |
| % | Reminder | int i=10%4; |
Unary Operators:
| Operator | Description | Example |
| + | Unary Plus | int i=+1; |
| - | Unary Minus | int i=-1; |
| ++ | Increment | int j=i++; |
| -- | Decrement | int j=i--; |
| ! | Logical Not | boolean j=!true; |
Equality Operators:
| Operator | Description | Example |
| == | Equality | if(i==1) |
| != | Non Equality | if(i!=1) |
Relational Operators:
| Operator | Description | Example |
| > | Greater than | if(x>5) |
| < | Less than | if(x<5) |
| >= | Greater than or equal to | if(x>=5) |
| <= | Less than or equal to | if(x<=5) |
Conditional Operators:
| Operator | Description | Example |
| && | Conditional and | if(a==4 && b==7) |
| || | Conditional or | if(a==4 || b==7) |
instanceof Operators:
| Operator | Description | Example |
| instanceof | Instance of | if(Jeep instanceof Vehicale) |
Bitwise Operators:
| Operator | Description | Example |
| & | Bitwise and | 001 & 111 =1 |
| | | Bitwise or | 001 | 110 = 111 |
| ^ | Bitwise ex-or | 001 ^ 110 = 111 |
| ~ | Reverse | ~011 = -10 |
Shift Operators:
| Operator | Description | Example |
| >> | Right shift | 4 >> 1 = 100 >> 1 = 010 = 2 |
| << | Left shift | 4 << 1 = 100 << 1 = 1000 = 8 |
| >>> | Unsigned Right shift | 4 >>>1 = 100 >>> 1 = 010 = 2 |
No comments:
Post a Comment
Hello Buddy, if you have any doubts or need any clarification , feel free to comment. Thanks.