Hello Friends!!!
In this article, we are going to learn different operators in Java to work on different operands.
What are the Operators?
Operators are the symbols to perform different operations on operands (values or variables).
There are three different types of operators available in Java.
Increment Operators: These types of operators increase the value of a variable with one value only.
Decrement Operators: These types of operators decrease the value of a variable with one value only.
It has two different types:
Binary operators work on two operands (variable/value). There are lots of different binary operators available in Java. Those are,
Example of Arithmetic Operator,
The output of the above program,
In the next article, we will learn more operators. Till then try with arithmetic operators.
Happy Coding...☺😊
In this article, we are going to learn different operators in Java to work on different operands.
What are the Operators?
Operators are the symbols to perform different operations on operands (values or variables).
There are three different types of operators available in Java.
- Unary
- Binary
- Ternary
Increment Operators: These types of operators increase the value of a variable with one value only.
Decrement Operators: These types of operators decrease the value of a variable with one value only.
It has two different types:
- Prefix Increment/Decrement
- For example, ++a Increases the value of a with one value
- --a Decreases the value of a with one value.
- Postfix Increment/Decrement
- For example, a++ Increases the value of a with one value
- a-- Decreases the value of a with one value.
Binary operators work on two operands (variable/value). There are lots of different binary operators available in Java. Those are,
=
|
Assignment
Operator
|
a=b (a=5)
|
Arithmetic Operators
|
||
+
|
Addition
|
a+b
|
-
|
Subtraction
|
a-b
|
*
|
Multiplication
|
a*b
|
/
|
Division
|
a/b
|
%
|
Modulus
|
a%b
|
+=
|
Addition
assignment
|
a+=b
|
-=
|
Subtraction
assignment
|
a-=b
|
*=
|
Multiplication
assignment
|
a*=b
|
/=
|
Division
assignment
|
a/=b
|
Example of Arithmetic Operator,
The output of the above program,
Fig. The output of the Arithmetic Operators |
Happy Coding...☺😊
No comments:
Post a Comment