有两种方法:
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){}