Convert float to string

J

Jack

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
 
S

Siam

Jack said:
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!
 
L

Lasse Reichstein Nielsen

Jack said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top