I have the below code.
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
System.out.println("Hardik::"+testFinnalyBlock());
}catch(Exception e){
System.out.println("hhh");
}
}
public static int testFinnalyBlock() throws Exception{
int a=5,b=10;
int sum=0;
try{
sum = a+b;
System.out.println("sum==="+sum);
return sum;
}catch(Exception e){
System.out.println("In Catch");
}finally{
sum = a+30;
System.out.println("sum==="+sum);
// return 1;
}
return 1;
}
The output of above code it Hardik::15, While i think it should be Hardik::35.
Can Anyone tell me how it works. Thanks.