For below program i am getting output as below.
Output:
In try
In finally
3
Why it is not returning 7 instead of 3?
public class MyFirstJavaProgram {
public static void main(String []args) {
int c = 10;
c=get(c);
System.out.println(c);
}
public static int get(int c){
try{
c=3;
System.out.println("In try");
return c;
}
catch(Exception e){
c=5;
System.out.println("In catch");
return c;
}
finally{
c=7;
System.out.println("In finally");
}
}
}