hi
why we can;t throw more than one excption in a try block as shown in below code.
public int method6() {
//throw new RuntimeException();
try{
throw new ArithmeticException();
throw new RuntimeException();
}
catch(RuntimeException re){
}
return 0;
}
but if we provide in the if else code then it will compiled
public int method6() throws Exception {
try{
int i = 1;
if (i==1){
throw new ArithmeticException(); }
else {
throw new RuntimeException();}
}
catch(RuntimeException re){
}
return 0;
}
why we can;t throw more than one excption in a try block as shown in below code.
public int method6() {
//throw new RuntimeException();
try{
throw new ArithmeticException();
throw new RuntimeException();
}
catch(RuntimeException re){
}
return 0;
}
but if we provide in the if else code then it will compiled
public int method6() throws Exception {
try{
int i = 1;
if (i==1){
throw new ArithmeticException(); }
else {
throw new RuntimeException();}
}
catch(RuntimeException re){
}
return 0;
}