我想使用 try-catch 块来处理两种情况:特定异常和任何其他异常。我可以这样做吗?(一个例子)
try{
Integer.parseInt(args[1])
}
catch (NumberFormatException e){
// Catch a number format exception and handle the argument as a string
}
catch (Exception e){
// Catch all other exceptions and do something else. In this case
// we may get an IndexOutOfBoundsException.
// We specifically don't want to handle NumberFormatException here
}
NumberFormatException 也会由底部块处理吗?