Java lets you cast down explicitly because it's useful sometimes. Remember, what we're really dealing with here are bits. So, in a 32 bit integer, 128 is 00000000000000000000000010000000. Casting...
Type: Posts; User: helloworld922
Java lets you cast down explicitly because it's useful sometimes. Remember, what we're really dealing with here are bits. So, in a 32 bit integer, 128 is 00000000000000000000000010000000. Casting...
Casting is casting. Implicit casting just means you don't have to specify what you're casting to, so Java will "implicitly" cast it for you.
int a = 5;
double b = a;
Java will see this as:...
Java will only implicitly cast upwards:
bytes -> shorts -> ints -> longs -> floats -> doubles -> String
(technically, char's can be cast to int's implicitly)
Anything else must be explicitly...