有两种方法:
1:
String snum = "12";
try{
int num = Integer.parseInt(snum);
}catch(NumberFormatException e){}2:
String snum = "12";
try{
int num = new Integer(snum).intValue();
}catch(NumberFormatException e){}
1:
String snum = "12";
try{
int num = Integer.parseInt(snum);
}catch(NumberFormatException e){}2:
String snum = "12";
try{
int num = new Integer(snum).intValue();
}catch(NumberFormatException e){}
String string1="12";
int int1=Integer.valueOf(String1).intValue();
int number = Integer.parseInt(num);