L024 | Implicit and Explicit (TYPE CASTING) Type Conversion in Java

1. Introduction to Type Casting

2. Why is Type Casting Required?

For example:

int num = 10;
double newNum = num; // Automatic widening

3. Types of Type Casting

Java provides two types of type casting:

Type Description
Implicit Type Casting (Widening) Automatic conversion of a smaller type to a larger type.
Explicit Type Casting (Narrowing) Manual conversion of a larger type to a smaller type using type casting.

4. Implicit Type Casting (Widening Conversion)

Widening Conversions Supported in Java:

byte → short → int → long → float → double