非数字抛出例外
java
try {
int tmp = Integer.parseInt(S);
System.out.println(tmp);
} catch (NumberFormatException ex){
System.out.println("Bad Data");
}
非法参数例外-自定义抛出信息
java
throw new IllegalArgumentException("n and p should be non-negative");