I'm trying to convert a double value to a float value using the floatValue() method. When I compile I keep getting the error - Method floatValue(double) not found in class. I've tried adding Import java.lang.Number.* but I get the same error. What am I doing wrong?
Hi.<br>
<br>
I just looked up type casting my java book. Which is what I think you want to do. something like <br>
<br>
floatVal=(float)doubleVal;<br>
<br>
Should do the trick. I remember from practice that sometimes javac doesn't like some casting but give it a go.<br>
<br>
The book i've got is "Java software solutions"-Lewis & Loftus. It's really good but it's on JDK 1.6 there probably is a new edition for 2.0 around.
Just read the legal thing that came when I signed up. Sorry sorry sorry. I am in no way affiliated with the publishers or authors of this book. In fact its a good idea to go into you local college/university/other training institiude witha good library and take some time to read through the guides and take some notes. It's a lot chaper that way and you only get what you need.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.