菜鸟提问:怎样把Int型转换成String?

bolobolobolobolo 2003-10-21 10:21:52
如果我要把一个Int拼装入一个String中该怎么操作,是不是要把Int转换成String型?
请各位高手指教!谢谢。
...全文
55 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
squallzeng 2003-10-21
  • 打赏
  • 举报
回复
1.) String s = String.valueOf(i);
2.) String s = Integer.toString(i);
3.) String s = "" + i;
skyfox3210 2003-10-21
  • 打赏
  • 举报
回复
好多的方法啊, bolobolobolobolo你现在满足了吧?
给你一个方法:
public String changeInttoString(int i_value){
String s_str = null;
try{
s_str = ""+i_value;
}catch(Exception e){
s_str = "";
}finally{
return s_str;
}

}
yaray 2003-10-21
  • 打赏
  • 举报
回复
int i=3;
String str = String.valueOf(i);
nnoo 2003-10-21
  • 打赏
  • 举报
回复
int i=1;
String str=String.valueOf(i);
whywzf 2003-10-21
  • 打赏
  • 举报
回复
或者:
int i=3;
String s =Integer.toString(i);
whywzf 2003-10-21
  • 打赏
  • 举报
回复
最简单是这样吧:
int i=3;
String s =""+i;//i自动变成string了,""中也可写入string内容
aku0708 2003-10-21
  • 打赏
  • 举报
回复
int count=123;
count.toString();
bolobolobolobolo 2003-10-21
  • 打赏
  • 举报
回复
我是想把Int转换成String型啊
foolfish 2003-10-21
  • 打赏
  • 举报
回复
int i=1;
String str=""+i;
3936525 2003-10-21
  • 打赏
  • 举报
回复
integer
squallzeng 2003-10-21
  • 打赏
  • 举报
回复
1). int i = Integer.parseInt([String]); 或
i = Integer.parseInt([String],[int radix]);
2). int i = Integer.valueOf(my_str).intValue();

81,090

社区成员

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

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