File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes a bit stumped Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "a bit stumped" Watch "a bit stumped" New topic
Author

a bit stumped

joew weakers
Ranch Hand

Joined: Aug 21, 2003
Posts: 48
Hey there. How does one cast a Float object to a String object or is that possible at all. I have a method which takes a string as argument and logs the string to a file. My program returns the scale of a map in a float format. I need to take this float value and output it to my logfile but I need to convert it to a string format first of all. You cannot cast a float to a string according to my compiler which seems fair enough. So how can I overcome this little burden. Thanks Joe
Arulkumar Gopalan
Ranch Hand

Joined: Oct 13, 2003
Posts: 104
How does one cast a Float object to a String object or is that possible at all.

you can use floatObject.toString() method to convert it as string.


Anbudan & Mahalo,<br />Arul<br /> <br />-Not a sun certified Java professional :-)
Arulkumar Gopalan
Ranch Hand

Joined: Oct 13, 2003
Posts: 104
static methods are also available.. check out the following URL to know what are all the methods available.
Java API
Michael Fitzmaurice
Ranch Hand

Joined: Aug 22, 2001
Posts: 168
Also, you can use implicit conversion with String concatenation, e.g.:


"One good thing about music - when it hits, you feel no pain" <P>Bob Marley
Michael Fitzmaurice
Ranch Hand

Joined: Aug 22, 2001
Posts: 168
Just to be clear about my previous post, that only works for primitives, i.e. float not Float, but you can get a float from a Float by calling the method floatValue() on it.
So float on...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: a bit stumped