Is there any benefit to returning the result of assigning a value to a local variable rather than the value directly?

前端 未结 6 1080
死守一世寂寞
死守一世寂寞 2021-01-17 09:01

I am doing a java code inspection. Here is a function (snippet):

String getValue() {
     String res;
     StringBuilder strBuilder = new StringBuilder();

         


        
6条回答
  •  太阳男子
    2021-01-17 09:27

    Just guessing, but some (most?) IDEs don't allow you to directly inspect the value of function returns. With this scheme, you could put a breakpoint at the end of the method, and mouse over "res" to get the return value.

提交回复
热议问题