Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 02-23-2009, 11:46 AM   #1
(╯□)╯︵ ┻━┻
Teny's Avatar
Join Date: Dec 2006
Location: United States
Posts: 5,957
Default need help with Type Casting

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

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.


EDIT - Nevermind, I got it.
Desktop -Cooler Master NV690/AMD Phenom II X4 965 BE/MSI 880G-E45 Motherboard/2 x 2GB DDR3 G.Skill Ripjaws X/Sapphire HD 5870 1GB GDDR5/CORSAIR CMPSU-550VX/Seagate 7200.12 500GB (OS), Samsung F3 1TB (Storage)/Sony DVD Burner/Windows 7 Professional 64-bit
Teny is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 04:56 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0