// TODO: 如果传入的参数为负,则抛出IllegalArgumentException
try {
if (salary < 0 || rate < 0) {
throw new IllegalArgumentException("警告,传入的参数为负!");
}
} catch (Exception e) {
// TODO: handle exception
System.out.println("-----------");
e.printStackTrace();
return salary * rate;
Sign in to make a reply
Best of Me
// TODO: 如果传入的参数为负,则抛出IllegalArgumentException
try {
if (salary < 0 || rate < 0) {
throw new IllegalArgumentException("警告,传入的参数为负!");
}
} catch (Exception e) {
// TODO: handle exception
System.out.println("-----------");
e.printStackTrace();
}
return salary * rate;
}