I\'ve written seven test cases for understanding the behavior of the finally
block. What is the logic behind how finally
works?
pac
Why builder = null
is not working?
Because you are setting the local reference to null which will not change the content of the memory. So it is working, if you try to access the builder after finally block then you'll get null.
Why builder.append("+1") work?
Because you are modifying the content of the memory using the reference,that's why it should work.
Why count++
does not work in testFive()?
It is working fine with me. It outputs 100 as expected.