xxxxxxxxxx
/* There are two types of typecasting in Java:
- Implicit
- Explicit
*/
// Implicit
byte b = 100;
int i = b;
// Explicit
int x = 100;
byte b = (byte) x;
xxxxxxxxxx
Assigning a value of one type to a variable of another type is
known as Type Casting.
Auto-boxing; is a process when you take a primitive value and
assign into wrapper class object.
Un-boxing; is a process when you take Wrapper class object
and convert to primitive.
xxxxxxxxxx
char letter = 'A';
int asciiValue = (int) letter;
System.out.println(asciiValue); // Output: 65
xxxxxxxxxx
int asciiValue = 65;
char letter = (char) asciiValue;
System.out.println(letter); // Output: A