- 表明向方法传递了一个不合法或不正确的参数
- 可手动抛出该异常,需要返回错误信息时可代替返回值:
public class TestHello {
public int[] twoSum(int[] nums, int target) {
for (...) {
......
}
throw new IllegalArgumentException("No two sum solution");
}
}