Operators are the symbol that performs some operations.Operator acts on variables. Those variables are called operands.
for example: c*d
Here c and d are operands where as * is an operator.
If an operator acts upon single operand then it is known as unary operator.If it acts upon two operand, they are called binary operator.
Arithmetic Operator
The operator that are used to perform fundamental operations like addition, subtraction, multiplication, division etc. are known as Arithmetic operator. There are five arithmetic operators in java. There are shown in the table.
for example: c*d
Here c and d are operands where as * is an operator.
If an operator acts upon single operand then it is known as unary operator.If it acts upon two operand, they are called binary operator.
Arithmetic Operator
The operator that are used to perform fundamental operations like addition, subtraction, multiplication, division etc. are known as Arithmetic operator. There are five arithmetic operators in java. There are shown in the table.
|
Operator
|
Function
|
Example
|
Outcome
|
|
+
|
Addition Operator
|
44+50
|
94
|
|
-
|
Subtraction Operator
|
50-44
|
6
|
|
*
|
Multiplication Operator
|
44*50
|
2200
|
|
/
|
Division Operator
|
50/25
|
2
|
|
%
|
Modulus Operator
|
45%25
|
20
|
Note :-
- Addition operator in java is also used to join two Strings.
- In java Strings are a type of class whereas in C/C++ It is a data type.
Logical Operators
These operators are used for logical operations or to construct compound condition, Compound condition is a combination of several simple sentences. There are Three logical operators-
- && And Operator
- || Or operator
- ! Not Operator
if(a==1 || c==1)
System.out.println("True");
In this statement any of a or c is equal to 1 then True will be shown
if(a==1 && c==1)
System.out.println("Fine");
In this statementif both a and c is equal to 1 only then "Fine " will be displayed
In next blog we will discuss on Unary and Boolean Operators
No comments:
Post a Comment