public class Main {
public static void main(String[] args) {
String a = "12";
String b = "x9";
// TODO: 捕获异常并处理
int c = stringToInt(a);
int d = stringToInt(b);
System.out.println(c * d);
}
static int stringToInt(String s) {
try {
return Integer.parseInt(s);
} catch (NumberFormatException e) {
throw new IllegalArgumentException(s + " is not integer");
}
}
}
韦雪松