Operators are some symbols which represent some specific actions on one or more operands to obtain a result. E.g., +, -, &, etc.
Unary Operator
Java Unary operator works on only one operand. Unary operators are used to perform the following operations:
- increment / decrement a value by 1
Click on the following two links for explanation of Increment and Decrement Operator.
- assigns negative expression
- complementing the boolan value
Binary Operator
Java Binary operator works on two operands. Any Arithmetic operator, Relational operator, Logical AND, OR, Bitwise AND, OR, XOR operator can Binary operator.
Ternary Operator
Java Ternary operator is used as the substitute of if-else statement. It is a one line statement. It is one and only operator which works on three operands.
The ternary operators are -
? - This is the substitute of if statement
: - This is the substitute of else statement
Click here to know more about ternary in details.
The ternary operators are -
? - This is the substitute of if statement
: - This is the substitute of else statement
Click here to know more about ternary in details.
Assignment Operator
Java Assignment operator is one of the most common operator which is used to store some value into a variable.
int a = 6
Here, the variable a is assigned with the value 6.
Here, the variable a is assigned with the value 6.
Arithmetic Operator
Java Arithmetic operators are used to perform common arithmetic operations like addition (+), subtraction (-), multiplication (*), division (/) and modulus (%).
Relational Operator
Java Relational operators are used to compare between two or more operands. It is also known as comparison operator. The relational operators are -
> : Greater than
< : Lesser than
>= : Greater than equal to
<= : Lesser than equal to
== : Equal to
!= : Not equal to
Bitwise Operator
> : Greater than
< : Lesser than
>= : Greater than equal to
<= : Lesser than equal to
== : Equal to
!= : Not equal to
To know more about operators in detail, see the following video:
Logical Operator
Java Logical operators are also known as Boolean operator because they operate on Boolean values (true, false). Java Logical operators are -
&& : Logical AND operator (Binary operator)
|| : Logical OR operator (Binary operator)
! : Logical NOT operator (Unaryoperator)
&& : Logical AND operator (Binary operator)
|| : Logical OR operator (Binary operator)
! : Logical NOT operator (Unaryoperator)
Bitwise Operator
Java Bitwise operators are used to perform the bit-by-bit operation and manipulations.
Java Bitwise operators are -
& : Bitwise AND (Binary operator) operator
| : Bitwise OR (Binary operator) operator
^ : Bitwise XOR (Exclusive OR) (Binary operator) operator
~ : Bitwise Complement (Unary operator) operator
>> : Bitwise Right Shift (Binary operator) operator
<< : Bitwise Left Shift (Binary operator) operator
Java Bitwise operators are -
& : Bitwise AND (Binary operator) operator
| : Bitwise OR (Binary operator) operator
^ : Bitwise XOR (Exclusive OR) (Binary operator) operator
~ : Bitwise Complement (Unary operator) operator
>> : Bitwise Right Shift (Binary operator) operator
<< : Bitwise Left Shift (Binary operator) operator
To know more about Logical and Bitwise Operators, see the following video:
0 Comments:
Post a Comment