Programming in Java Programming in Java: Anonymous Inner Class Anonymous Inner Class (Contd.)
Programming in Java Programming in Java: Anonymous Inner Class Anonymous Inner Class (Contd.)
1
4/19/2021
2
4/19/2021
Type Casting Primitive Data Types Type Casting Primitive Data Types (Contd.)
A primitive data type supports two types of type casting: Consider the following code snippet that casts the integer number
Implicit casting to the byte type:
Explicit casting int a = 10;
Implicit casting: byte b = (byte) a;
Refers to an automatic conversion of one data type into another. System.out.println(b);
Occurs if both the data types are compatible with each other.
Consider the following code snippet of the implicit casting:
int a = 100;
long b = a;
Explicit casting occurs when one data type cannot be implicitly
converted into another data type.
In case of explicit conversion, you must convert the data type into
the compatible type.
3
4/19/2021
Microsoft Word
Document
Programming in Java