TYPECASTING AND OPERATORS
COMPUTER PROGRAMMING 1
B y : Te l e s e r M e j o r a d a a n d F r e e c a
To r c u l a s
INTRODUCTION
W H AT I S T Y P E C A S T I N G ?
“()”
• It is used in computer programming to ensure
a function handles the variables correctly.
• Type casting is when you assign a value of
one primitive data type to another type.
2
TWO TYPES OF
TYPECASTING
I M P L I C I T E X P L I C I T
converting a smaller type to converting a larger type to a
a larger type size smaller size type
byte -> short -> char -> int -> long double -> float -> long -> int
-> float -> double -> char -> short -> byte
For example For example
Int i = 10; Long L= 10000;
Long L= i; Int i = (int) L;
This is implicit casting This is Explicit Casting
“Implicit Casting is done by the Explicit Casting done manually by
compiler automatically” placing the type in parentheses in
front of the value. 3
I M P L I C I T E X P L I C I T
4
JAVA
OPERATORS
Operators are used to perform operations on
variables and values.
Java divides the operators into the
following groups:
•Arithmetic operators
•Assignment operators
•Comparison operators
•Logical operators
•Bitwise operators
5
ARITHMET
IC
OPERATOR
S
6
JAVA
ASSIGNMEN
T
OPERATORS
7
JAVA
COMPARISO
N
OPERATORS
8
JAVA
LOGICAL
OPERATO
RS
9
JAVA
BITWISE
OPERATORS
10
THANK YOU FOR LISTENING