Here is the code to demonstrate my point (java):
public static int getSize(List<String> list)
{
System.out.println("begin");
try
{
System.out.println("get list size");
return list.size();
}
catch (Exception e)
{
System.err.println("exception");
}
finally
{
System.out.println("finally");
return -1;
}
}
public static void main(String[] args)
{
List<String> list = null;
int size = getSize(list);
System.out.println("list size: " + size);
}
I expected the output of:
begin
get list size
exception
finally
list size: -1
instead I get other stuff and the one above as well... like the exception can show before get list size and after exception...
e.g.
begin exception get list size finally list size: -1
and
begin get list size finally exception list size: -1
Why is it doing this? What is the correct output?