Pertemuan 5 - OPERATOR

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

/ &

* |
Algoritma
-
Pemrograman
+ OPERATOR >=
< <=
= !
Operators are used to perform operations on variables
and values

• Example “+” operator is often used to add together two values, it can
also be used to add together a variable and a value, or a variable and
another variable:
Java divides the operators into the following
groups:
• Arithmetic operators

• Assignment operators

• Comparison operators

• Logical operators

• Bitwise operators
Arithmetic Operators
+ Addition Adds together two values
- Subtraction Subtracts one value from another

* Multiplication Multiplies two values


/ Division Divides one value by another

% Modulus Returns the division remainder

++ Increment Increases the value of a variable by 1

-- Decrement Decreases the value of a variable by 1


Java Assignment Operators
Assignment operators are used to assign values to
variables.

X = 10;
Java Assignment Operators
Operator Example Same As
= x=5 x=5

+= x += 3 x=x+3

-= x -= 3 x=x-3

*= x *= 3 x=x*3

/= x /= 3 x=x/3

%= x %= 3 x=x%3
Java Comparison Operators
Operator Name
== Equal to
Comparison != Not equal
operators are used > Greater than
to compare two < Less than
values: >= Greater than or
equal to
<= Less than or equal to
Java Logical Operators
Operator Name Description
Logical operators are used to &&  Logical and Returns true if both
statements are true
determine the logic between ||  Logical or Returns true if one of the
statements is true
variables or values: ! Logical not Reverse the result, returns
false if the result is true
+

You might also like