Hi all,
I have a question regarding best practice in using local variables as my method return variable.
I have a method like this
myReturnObject getMyObject(String input) { myReturnObject myObject = null; try { myObject = helperObject.someOtherMethod().getObject(input); //getObject has return type myReturnObject } catch (Exception e) { //log any problems } return myObject; }
And I'm wondering if I rewrite like this if I'll see some performance optimization benefit
myReturnObject getMyObject(String input) { try { return helperObject.someOtherMethod().getObject(input); //getObject has return type myReturnObject } catch (Exception e) { //log any problems } return null; }
myObject can be quite large -- so I'm wondering if I can omit the myReturnObject local variable instance if it'll save some work from the garbage collector.
I welcome your input!
Thanks,
-Wolf