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

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

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -