Java's strange behavior while returning from finally block

后端 未结 6 2167
梦谈多话
梦谈多话 2021-01-02 03:26

Try this piece of code. Why does getValueB() return 1 instead of 2? After all, the increment() function is getting called twice.

    public class ReturningF         


        
6条回答
  •  耶瑟儿~
    2021-01-02 03:49

    the finally block in GetValue2 method does not return anything. It's only calling the method to increment counter.

提交回复
热议问题