I am doing a java code inspection. Here is a function (snippet):
String getValue() {
String res;
StringBuilder strBuilder = new StringBuilder();
You cant do either
String res = strBuilder.toString();
return res ;
Or directly,
return strBuilder.toString();
Now If you want to know about benefits as you asked Is there any benefit, i always prefer directly return. My personal logic is simple as
GC to collect it. SO, less memory see..... Those things are nothing big, I had to say as you asked