Casting Against Type
A value could be two different types
Is 12 an int or a float?
Compiler isnít smart, so itís conservative (signals an error)
Override the compiler with a cast
Cast says: Treat this variable as the type I say
To cast in Java, write:
(newType) variable
Previous slide
Next slide
Back to first slide
View graphic version