lifetime of variable in java
<pre><code>private void func()
{
  String str = "hi!";
}
</code></pre>

<p>this is my code.</p>

<p>suppose I called func() in the onCreate event.
I want to the near exact time, if thats possible to be determined, when GC will free the memory used by str.</p>

<p>Actually str stores a password.
and i want to free it as soon as I can.
currently after using str I set its value to something irrelevant.</p>

<p>I heard GC is the only thing that can free memories?
is that correct?
is there any other way of freeing the memory of a variable.</p>
