Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

Convert float to string

Thread view: 
Jack - 20 Mar 2008 20:37 GMT
hexcalc.java:119: toString() in java.lang.Object cannot be applied to
(float)
      System.out.println (Math.toString(theExp));
                              ^
1 error

theExp is of type float
Any help would be greatly appreciated!
Thanks
Jack
Siam - 20 Mar 2008 20:56 GMT
> hexcalc.java:119: toString() in java.lang.Object cannot be applied to
> (float)
>        System.out.println (Math.toString(theExp));
>                                ^
> 1 error

What are you trying to do? To print the float,
System.out.println(theExp) will do. The toString method is a non-
static method (which takes no arguments) that you call on objects...
You've called it it statically on the Math class, passing it a
primitive... Thats why the compiler's complained!
Lasse Reichstein Nielsen - 20 Mar 2008 21:39 GMT
> hexcalc.java:119: toString() in java.lang.Object cannot be applied to
> (float)
>        System.out.println (Math.toString(theExp));
>                                ^
> 1 error

> theExp is of type float

As was already said, just
System.out.println(theExp)
will do.

You might have been thinking of
Float.toString(float)
There is no Math.toString(float).

/L
Signature

Lasse Reichstein Nielsen  -  lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
 'Faith without judgement merely degrades the spirit divine.'

Roedy Green - 21 Mar 2008 00:42 GMT
>hexcalc.java:119: toString() in java.lang.Object cannot be applied to
>(float)
>       System.out.println (Math.toString(theExp));

see http://mindprod.com/applet/converter.html
for how to interconvert all the common types.

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.