Is there any performance reason to declare method parameters final in Java? -


is there performance reason declare method parameters final in java?

as in:

public void foo(int bar) { ... } 

versus:

public void foo(final int bar) { ... } 

assuming bar read , never modified in foo().

the final keyword not appear in class file local variables , parameters, cannot impact runtime performance. it's use clarify coders intent variable not changed (which many consider dubious reason usage), , dealing anonymous inner classes.

there lot of argument on whether final modifier on method has performance gain since methods inlined optimizing compiler @ runtime anyway, regardless of modifier. in case should used restrict overriding of method.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -