Hello Fengqiao,
I think I understand the source of your confusion, but please elaborate if I misunderstand you. If you are wondering why it is that the method returns -1 instead of returning 0 , then one has to understand that when a statement in a try-block throws an exception, the execution flows down to the matching catch statement. If there is not a catch-block that can deal with the type of exception thrown in the try-block, the execution procedes directly to the finally statement, and then the execution flows up to the method that called the method containing the try-block, the rest of the code inside the method that contained the try-block does NOT execute. Therefore the return 0 statement at the bottom of the method never executes. If you want this method to return 0, place the return 0 statement inside the finally block, where it will override the return -1 statement in the catch-block.
finally{
System.out.println("Doing finally");
return 0;
}
Hope I helped!