【发布时间】:2023-12-14 23:17:01
【问题描述】:
我正在从文本文件中读取信息,如果读取的类型无效,我希望我的代码抛出异常。但是,我不知道在发现异常后如何让我的程序继续运行
while(input.hasNext()) {
try{
type = input.next();
name = input.next();
year = input.nextInt();
} catch(InputMismatchException ex)
{
//System.out.println("** Error: Invalid input **");
//code to make program continue
}
}
【问题讨论】:
标签: java exception-handling try-catch