Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in Java only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Member List
Calendar
Today's Posts
Home
Forum
Topic
Java
corejava
corejava
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
arunareddy
New Member
Join Date:
May 2007
Posts:
1
#1
corejava
May 12 '07, 05:31 AM
hi,
can u tell me how to convert a double value(10.0) to String value "10.00"
rsrinivasan
New Member
Join Date:
Mar 2007
Posts:
221
#2
May 12 '07, 05:41 AM
Hi,
You can convert double value to string value by using valueOf() function of String class.
For Example:
public class ConvertDouble
{
public static void main(String[] args)
{
double d=4.0;
String str= String.valueOf( d);
System.out.prin tln(str);
}
}
Comment
Post
Cancel
JosAH
Recognized Expert
MVP
Join Date:
Mar 2007
Posts:
11453
#3
May 12 '07, 06:15 AM
Originally posted by
arunareddy
hi,
can u tell me how to convert a double value(10.0) to String value "10.00"
If you want those two decimal digits you have to use a
DecimalFormat
.
kind regards,
Jos
Comment
Post
Cancel
parthpatel
New Member
Join Date:
Apr 2007
Posts:
14
#4
May 12 '07, 09:14 AM
update
class convert {
double d = 4.0;
String s = ' ' + d;
System.out.prin tln(s);
}
Last edited by
parthpatel
;
May 12 '07, 09:17 AM
.
Reason:
Problem writing script
Comment
Post
Cancel
parthpatel
New Member
Join Date:
Apr 2007
Posts:
14
#5
May 12 '07, 09:25 AM
class convert {
public static void main(String args[]){
double d = 4.0;
String s = ' ' + d;
System.out.prin tln(s);
}
}
Comment
Post
Cancel
Previous
template
Next
Working...
OK
OK
Cancel
👍
👎
☕
Comment