求助 !如何把String 型转换成int型?

yasu1984 2005-10-25 10:38:47
比如
String a = "80";
如何转换成int型的80
谢谢
...全文
518 17 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
lcllcl987 2005-10-25
  • 打赏
  • 举报
回复
String a = "80";
int i = Integer.parseInt(a,10);
jordan1 2005-10-25
  • 打赏
  • 举报
回复
经常用到的
scriptren 2005-10-25
  • 打赏
  • 举报
回复
用 Integer.parseInt 的方法试试看
szuzsq 2005-10-25
  • 打赏
  • 举报
回复
^
pingfan520 2005-10-25
  • 打赏
  • 举报
回复
楼上的说的对
int i=new Integer("80").intValue();
zhiaizhishou 2005-10-25
  • 打赏
  • 举报
回复
public static int stringToInt(String str){
if(str==null||str.trim().equals("") ){
return 0;
}
return Integer.parseInt(str);
}
weiming_11000 2005-10-25
  • 打赏
  • 举报
回复
String a="80"
int x=Integar.parseInt(a);
希偌 2005-10-25
  • 打赏
  • 举报
回复
int i=new Integer("80").intValue();
taile 2005-10-25
  • 打赏
  • 举报
回复
String a = "80";
int n = Integer.parseInt(a)
cjhyahoo 2005-10-25
  • 打赏
  • 举报
回复
String a = "80";
int n = Integer.parseInt(a)
saiche05 2005-10-25
  • 打赏
  • 举报
回复
String a = "80";
int n = Integer.parseInt(a)
eden zsx 2005-10-25
  • 打赏
  • 举报
回复
haha
ianok 2005-10-25
  • 打赏
  • 举报
回复
public static int transStringToInt(String string) {
if (string == null || "".equals(string)) {
return 0;
}
return Integer.parseInt(string);
}
Mark_Chen 2005-10-25
  • 打赏
  • 举报
回复
String a = "80";
int i = Integer.parseInt(a);
yyouyou 2005-10-25
  • 打赏
  • 举报
回复
不过要注意抛出异常:)
boyu_song 2005-10-25
  • 打赏
  • 举报
回复
Integer.parseInt(a);
这个就是对的。
riancoat 2005-10-25
  • 打赏
  • 举报
回复
-_-!```这种问题~~~ 真经典!够难度!

62,634

社区成员

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

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