Java: Do global variables save memory and/or time?
<p>I am working on an Android app and a method I am writing might get called a bunch of times. In this method I am making updates to the user interface. Memory use and performance are important to me. The way I see it, I have 2 options for making the UI changes. </p>

<p>The first is to makes new objects every time. That is to say something like:</p>

<pre><code>public void myMethod(){
new View().makeVisible();
}
</code></pre>

<p>The second is to declare the object as a variable globally and reference it in the method. This might look like:</p>

<pre><code>View myView = new View();

public void myMethod(){
myView.makeVisible();
}
</code></pre>

<p>Obviously the if this method only called a few times any difference is going to be small. However if I am potentially calling this many times, and there are many variables being call/or created this way, does the second way increase performance?</p>
