For example:
public Person newPerson() {
Person p = new Person("Bob", "Smith", 1112223333);
return p;
}
as opposed to:
public Person newPerson() {
return new Person("Bob", "Smith", 1112223333);
}
Is one more efficient than the other?
There isn't any difference that would make you chose one over the other in terms of performance.
In general, I'd advice for the latter, and whenever you need to debug this, make a temporary switch to the first (two-line) variant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With