Thursday, February 25, 2010

Programmer - Is it better to create a new object and return it or create the new object in the return statement?

Programmer Question

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?



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails