📜  我们可以在单个 catch 块中捕获多个异常吗?无论代码示例

📅  最后修改于: 2022-03-11 14:58:44.939000             🧑  作者: Mango

代码示例1
From Java 7, we can catch more than one exception with single catch block. 
This type of handling reduces the code duplication.

When we catch more than one exception in single catch block , 
catch parameter is implicity final. We cannot assign any value to catch 
parameter.

Ex : catch(ArrayIndexOutOfBoundsException || ArithmeticException e){
20
}

In the example e is final we cannot assign any value or 
modify e in catch statement