Thread: Integer Usage
View Single Post
  #6 (permalink)  
Old 01-23-2008, 07:09 AM
CaptainMorgan's Avatar
CaptainMorgan CaptainMorgan is offline
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
blue, please review this tutorial and even this example. Use Google until you're satisfied you've discovered your understanding. Simply put, casting is the forcing of one type to another.

And for your problem.. in that situation you want to cast the computation in computeAverage() to a double. However, not to confuse you, but this will not work as trying to cast an int - which has already been truncated, will not produce your desired effect. Instead, you might want to change every int you already have into a double(static double a = 53; ). From there, you can down-cast to an int if you need it. Is there a reason you're using int's specifically? You can't up-cast from an int to a double and expect precision.... something to consider.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Reply With Quote