For instance:
public Person newPerson() { Person p = new Person("Bob", "Smith", 1112223333); return p; }
Unlike:
public Person newPerson() { return new Person("Bob", "Smith", 1112223333); }
Is it more effective than the other?
Assigning a temporary variable before returning gives you the ability to check and correct errors from your newPerson (). Returning a new call requires calling your newPerson () method to detect and recover from errors.
There is no difference that would make you choose one from another in terms of performance.
, , , , () .
, , JIT .
-, . :
: return p. .
p
, , .
, , . , , ?: -)
, , , , . , final .
final
.
, Java- .