BruteForceX
Tech Revolutionist
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
300 XP
Introduction:
Hello, this page will teach you about another two types of Operators in Java, Arithmetic and Unary.
Arithmetic Operators - What are they?
Arithmetic Operators are symbols used to perform a mathematical sum. There are five types of these:
+
Add
-
Subtract
/
Division
*
Multiplication
%
Modular/Remainder
All of these operators have clear uses for anyone with basic knowledge of Math.
Unary Operators - What are they?
Unary Operators are used to manipulate a number value - at least, that's what I say. Again, there are five types of Unary Operators:
+
Indicates Positive Value
-
Negates An Expression
++
Increments Value by 1
--
Decrements Value by 1
!
Inverts Boolean Value
Examples:
Here is an example of how Arithmetic Operators are used:
which gives the output:
2
3
1
50
16
6
And here is an example of how to use Unary Operators:
Which gives the output:
2
3
2
Finished!
Book traversal links for Arithmetic and Unary Operators
Hello, this page will teach you about another two types of Operators in Java, Arithmetic and Unary.
Arithmetic Operators - What are they?
Arithmetic Operators are symbols used to perform a mathematical sum. There are five types of these:
+
Add
-
Subtract
/
Division
*
Multiplication
%
Modular/Remainder
All of these operators have clear uses for anyone with basic knowledge of Math.
Unary Operators - What are they?
Unary Operators are used to manipulate a number value - at least, that's what I say. Again, there are five types of Unary Operators:
+
Indicates Positive Value
-
Negates An Expression
++
Increments Value by 1
--
Decrements Value by 1
!
Inverts Boolean Value
Examples:
Here is an example of how Arithmetic Operators are used:
- int
tutorial =
2
;
- System
.out
.println
(
tutorial)
;
- tutorial =
tutorial +
1
;
- System
.out
.println
(
tutorial)
;
- tutorial =
tutorial -
2
;
- System
.out
.println
(
tutorial)
;
- tutorial =
tutorial *
50
;
- System
.out
.println
(
tutorial)
;
- tutorial =
tutorial /
3
;
- System
.out
.println
(
tutorial)
;
- tutorial =
tutorial %
10
;
- System
.out
.println
(
tutorial)
;
which gives the output:
2
3
1
50
16
6
And here is an example of how to use Unary Operators:
- int
tut =
2
;
- System
.out
.println
(
tut)
;
- tut++;
- System
.out
.println
(
tut)
;
- tut--;
- boolean
opposite =
false
;
- if
(
!
opposite)
{
- System
.out
.println
(
tut)
;
- }
Which gives the output:
2
3
2
Finished!
Book traversal links for Arithmetic and Unary Operators
- ‹ Assignment + Equality and Relational Operators
- Up
- Conditional and Type Comparison Operators ›