Does declaring variables as final, inside methods, improve performance?

aurelius :

Does declaring variables as final inside a method brings any benefit from a performance/memory point of view in the latest java versions?

I am not talking here about any other benefit.

This question Does use of final keyword in Java improve the performance? was addresed almost 7 years ago, some progress has been done since then.

apangin :

No, final keyword on a local variable has no performance impact, and it cannot have even in theory, since .class files do not retain this information.

See this answer for details.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=440659&siteId=1
Recommended