Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-28-2007, 12:00 PM
mew mew is offline
Member
 
Join Date: Nov 2007
Posts: 70
mew is on a distinguished road
Float to String
Code:
float f = 10.23f;
I want to convert this float to a String. How to do this.

Thanks in advance
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-28-2007, 01:06 PM
Member
 
Join Date: Dec 2007
Posts: 5
beserie is on a distinguished road
to ways to do this.....

Just use it as a string.... As in this example :

String str;
float f = 12.23;
str = "bla bla bla"+f;

the result is a string containing "bla bla bla12.23"
if you just want the float, juste concatenate it to an empty string (str= ""+f; )

OR
explicitly transform it using the appropriate method :
str = f.toString();

ET C'EST CAISSE ;-)
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-28-2007, 01:11 PM
Member
 
Join Date: Dec 2007
Posts: 5
beserie is on a distinguished road
You have to consider de float F as an object of the Float class.
because it IS an object of that class.

then check : Float (Java 2 Platform SE v1.4.2)

to know all you can do with that object.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-28-2007, 05:11 PM
Senior Member
 
Join Date: Jun 2007
Location: Bali, ID
Posts: 100
wsaryada is on a distinguished road
You can do String.valueOf(float);
__________________
Website:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- Blog:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 12-29-2007, 06:08 PM
mew mew is offline
Member
 
Join Date: Nov 2007
Posts: 70
mew is on a distinguished road
Thanks all of you. It worked.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
String to Float durahman New To Java 2 02-12-2008 01:17 AM
convert string to float miss_dot NetBeans 1 11-15-2007 12:26 AM
Error with convert to Float cachi New To Java 1 08-06-2007 03:18 AM
Help with valid declarations of a float baltimore New To Java 1 07-31-2007 11:28 AM
Class float Peter New To Java 1 07-08-2007 02:17 AM


All times are GMT +3. The time now is 08:10 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org