我有一个关于抛出哪个异常以下疑问,如果列表为空如果在java中列表为空,抛出哪个异常?
public class XYZ implements Runnable {
private List<File> contractFileList;
@Override
public void run() {
contractFileList = some method that will return the list;
//now i want to check if returned contractFile is empty or not , if yes then raise the exception
if (contractFileList.isEmpty()) {
// throw new ?????
}
}
}
我乳宁批这里面的代码,我想抛出一些异常,将停止执行批处理。
谢谢Jon ... !!是的你是对的我不能在Runnable.run()中使用检查过的excpetions。所以我使用IllegalStateException – Beginner
'if(contractFileList.isEmpty()){ throw new IllegalStateExcpetion(“contractFileList is empty”); – Beginner
希望这是正确的。请注意 – Beginner