On Jan 28, 1:53 am, Tim Russell <[email protected]> wrote:
> I believe final local variables are usually placed on the heap for extended
> lifetime (for use in inner classes), so is their a runtime overhead rather
> than using simple locals (which use Dalvik registers)?

Doing something like this:

  public void blah() {
      final int numThings = 12;
      int i = 0;
      ...
  }

is effectively just documentation for programmers reading your code.
The javac compiler knows which local variables are changed and which
aren't (as well as which are set but never referenced, or never used
at all).  Using the "final" keyword on locals will not alter the
compiler's output.  It's not visible to the VM either.

The only time you need to use it is when the variable is referenced by
an anonymous inner class (the compiler will let you know).

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to