Core Java - Part 40 - Types of Type Casting

preview_player
Показать описание

In this video, I have explained and practically demonstrated different types of Type Casting in Java.

- Widening Type Casting
- Narrowing Type Casting
Рекомендации по теме
Комментарии
Автор

If implicit type casting works only when the size of the literal is SMALLER than the size of the data type, then how does char get implicitly tyoecasted to 'byte' and 'short' data types (and 'int' gets implicitly typecasted to 'char')? The order clearly states that the size of byte < short < char < int. So, how does the following statements get implicitly converted?

1. char a = 115;
2. byte d = 's';
3. short e = 'f';

Please explain. Thanks

titirmisra