Learn Java Programming - Primitive Numeric Type Casting Tutorial

preview_player
Показать описание
There will be situations when you need to assign one data type the value of an incompatible data type. If you watched my tutorial on Primitive Numeric Type Conversions, then you learned about variable assignments of compatible data types. Incompatible data types can be assigned to one another using a cast. A cast tells the javac compiler to convert one type into the other; by doing so, there may be loss of data. You are telling the compiler that you know best and to ignore warnings and compile away.
Рекомендации по теме
Комментарии
Автор

i've got my oca jp7 coming up, and was looking for conversion and promotion material.

clearly i've got the wrong link, but it sounds like you've got a video on that (i've only watched this one), but regardless this video is a breath of fresh air. you seem to get your points across clearly, and go into the relevant details. youtube is awash with piss poor explanations and 'training' companies.

if you can keep up this level of clarity and maybe focus on the oca and similar levels of detail you will smash it!

subscribed.

ps - really like the video quality, but get a better mic / room! :)

*edit: oh wow, ok you aren't messing about, just checked your other videos. nice!

nickwoodward
Автор

Your tutorials are so concise and to the point. Great work!
Can you tell me why is type casting important? Why would we want to convert an int variable to a long and a long variable type to an int? I understand the methods used. Just need clarification as to why should we do this?

siddharthadas
Автор

One Reason to cast float to byte Ive seen is in graphics where someone is implementing a ray tracer that outputs to ascii for rendering

ChrisAthanas