希望能帮助你。
public class Test {
public static Integer atoint(String str){
Integer result = 0;
try {
result = Integer.parseInt(str);
} catch (Exception e) {
System.out.println("字符串转int失败!");
}
return result;
}
public static void main(String[] args) {
String testStr = "123";
Integer atoint = atoint(testStr);
System.out.println("转换结果:" + atoint);
}
}
Double.parseDouble(String s);
//字符串转整数
int num = Integer.parseInt(str);