Should we pass argument to a method as a variable or as a new object directly in java
<p>Consider the following two calls to the same method in java:-</p>

<p>1) <code>doSomething(new Object[]{"something"}) ;</code> </p>

<p>2) </p>

<pre><code>Object[] obj = {"something"} ;

doSomething(obj);
</code></pre>

<p>Which one is more efficient in terms of memory and time efficiency ? I would say the 1) is better in both memory and time efficiency. Reason being in the second option requires us to create another variable (extra memory) and then assigns that value to the variable (extra time). Any comments ? </p>

<p>Just to clarify the object will be create only once, i am talking about the extra variable being used to hold the address of the newly created object.</p>
