Java Operator
Java Operator
OPERATORS
COMPUTER PROGRAMMING 2
“Life is like a Java Programming,
A small mistake.. And there will
be a Syntax ERROR!”
- ASHK ARS AL AN
MOTIVATION
Put data types and variable to the following
data to make it as a complete line of codes:
1. 12
2. a
3. 0.2
Java Operators
An operator is a symbol that performs operations on
variables and values. These are the different types of
operators in java: Arithmetic, Increment or Decrement,
Relational, Logical, and Conditional.
Arithmetic Operators
These operators involve the mathematical operators
that can be used to perform various simple or advanced
arithmetic operations on the primitive data types referred
to as the operands.
Arithmetic Operators
Arithmetic Operators
1. Addition (+): This operator is used to add two
operands.
Syntax:
num1 + num2
Example:
int num1 = 4;
int num2 = 3;
int sum = num1 + num2;
Arithmetic Operators
2. Subtraction (-): This operator is used to subtract two
operands.
Syntax:
num3 – num4
Example:
int num3 = 5;
int num4 = 2;
int difference = num3 - num4;
Arithmetic Operators
3. Multiplication (*): This operator is used to multiply
two operands.
Syntax:
num5 * num6
Example:
int num5 = 10;
int num6 = 7;
int product = num5 * num6;
Arithmetic Operators
4. Division (/): This operator is used to multiply two
operands.
Syntax:
num7 / num8
Example:
int num7 = 10;
int num8 = 5;
int quotient = num7 / num8;
Arithmetic Operators
5. Modulus (%): This is to return the remainder when the
first operand(dividend) is divided by the second
operand(divisor).
Syntax:
num9 % num10
Example:
int num9 = 10;
int num10 = 5;
int quotient = num9 % num10;
Demonstration in IDE
Dcoder for mobile
Java Online GDB for
Desktop/PC/Laptop.
Task:
INSTRUCTION: Answer the following questions in one or two
sentences.
1. What is Arithmetic Operator?
2. What is the use of Arithmetic Operators in programming?
Abstraction:
In your own understanding
what can you say about
Arithmetic Operators?