java中int, double 转化成String, String转化成double,怎么做?请给个例子.

blueradish 2001-07-14 10:58:32
...全文
268450 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
blueradish 2001-07-14
  • 打赏
  • 举报
回复
都对阿.糟了,怎么给分啊.我加10分,每个10分吧.
顺便问一下,你们熟悉各种control和Variant, safeArray和我联络

icq: 36352861 (不是QQ)
MSN Message: blueradish66@hotmail.com
I am online now.
ungerent
xuxk 2001-07-14
  • 打赏
  • 举报
回复
public class trans{

public static void main(String ag[]){
int a = 12;
double b = 122;
String s1 = a + "";
String s2 = b + "";

System.out.println("s1 and s2: "+s1+" "+s2);

String s = "12345";
try{
double d = (new Double(s)).doubleValue();
System.out.println("d: "+d);
}
catch(NumberFormatException e){
System.out.println("s is not a number");
}
}
}
knight_qmh 2001-07-14
  • 打赏
  • 举报
回复
不好意思写错了,
double dd = Double.parseDouble("123.2");
packy_li 2001-07-14
  • 打赏
  • 举报
回复
int 转化成String:
int i=10;
String str=Integer.toString(i);
double 转化成String:
double d=10.0;
String str=Double.toString(d);
String 转化成double:
String str="123456";
double d=Double.valueOf(str).doubleValue();
knight_qmh 2001-07-14
  • 打赏
  • 举报
回复
int i = 10;
double j=1.0;
String str_i=Integer.toString(i);
String str_j = Double.toString(j);

double dd = Double.valueOf("123.2");

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧