Teny
(╯°□°)╯︵ â”»â”â”»
- Messages
- 5,957
- Location
- United States
So i got this homework where i got stuck at. My class is using Java.
I dont quite understand what Type Casting do, or how to do it. Heres the problem
Now, Im not asking you guys to do my homework for me. But maybe make it a bit easier for me to understand. I read the section in the book, and a couple things I googled, and I just got lost. Any help would be appreciated, and if you can, do an example from above if possible.
Thanks
EDIT - Nevermind, I got it.
I dont quite understand what Type Casting do, or how to do it. Heres the problem
Assume the following declarations
int integer ;
double preciseReal ;
float sloppyReal ;
long bigInteger ;
Rewrite those of the following statements which would generate a compile-time error using an appropriate cast that makes the error go away. Do not provide a cast for any statement which the compiler automatically promotes.
a) integer = preciseReal ;
b) bigInterger = sloppyReal ;
c) preciseReal = integer ;
d) sloppyReal = bigInteger ;
e) integer = sloppyReal ;
f) bigInteger = preciseReal ;
g) sloppyReal = integer ;
h) preciseReal = bigInteger ;
i) integer = bigInteger ;
J) sloppyReal = preciseReal ;
k) preciseReal = sloppyReal ;
l) bigInteger = integer ;
Now, Im not asking you guys to do my homework for me. But maybe make it a bit easier for me to understand. I read the section in the book, and a couple things I googled, and I just got lost. Any help would be appreciated, and if you can, do an example from above if possible.
Thanks
EDIT - Nevermind, I got it.