public class
Test {
public static
String output="";
public static void foo(int i)
{
try{
if(i==1)
{
throw new Exception();
}
System.out.println(output +="1");
}
catch(Exception e)
{
System.out.println(output+="2");
return;
}
finally{
System.out.println(output+="3");
}
System.out.println(output+="4");
}
public static void main(String[]arf)
{
foo(0);
foo(1);
}
}
I thought the output will be 134234,but the output is 13423.
Why when the Exception is throw System.out.println(output+="4") not executed......can anybody explain this.