String转int
String str = “123”;
方法1:
int a = Integer.parseInt(str);
方法2:
int b = Integer.valueOf(str);
可能报错 : NumberFormatException
错误:
int a = Integer.getInteger(str) 方法不行.
public static int parseInt(String s) throws NumberFormatException {
throw new RuntimeException(“Stub!”);
}
public static Integer valueOf(String s) throws NumberFormatException {
throw new RuntimeException(“Stub!”);
}
//可能是跟拆装箱有关的方法吧
public static Integer getInteger(String nm) {
throw new RuntimeException(“Stub!”);
}