What is type casting?
Type causing is when u assign a value of one primitive data type to another type.
Are there types of type casting?
Yes, two. Widening casting and narrow casting.
What is widening casting?
It’s converting a smaller type to a larger type size.
What’s narrowing casting?
It is when you convert a larger type to a smaller size type.
Example of widening casting?
It is done automatically.
Example.
public class Main 〔
public static void main(String[] args) 〔
int myInt = 9;
double myDouble = myInt; // Automatic casting: int to double System.out.println(myInt); //prints 9 System.out.println(myDouble); //prints 9.0
〕 〕If you use narrow casting on a value 9.78, what does it become?
9