File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ranch Office and the fly likes Final modifier applied to local variables - Java performance tuning Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Ranch Office
Reply locked New topic

Final modifier applied to local variables - Java performance tuning

Kevin Hermann

Joined: Aug 12, 2010
Posts: 7

A few developers in my company have encountered websites that claim that using the final modifier on local variables creates a slight performance boost for a Java application.  We are using WebSphere Portal 6.1 and WAS 7.0 and we use JSR 168/286 Portlets, EJB 3.0, Web Services, and Java 6. It's just that if the final modifier on local variables was truly a performance tuning tip I'm sure it would be general Java knowledge and would have been covered in the official SCJP book (Kathy & Bert). Using a final modifier should only be applied to a variable if a client with access to that variable has an opportunity to change the object it is referring to and this behavior is not desired.

Yesterday I posted this thread on the JSP forum and it appears to have been moved. This morning I was looking for this thread to see if anyone else had provided replies.

If anyone with expertise in this area can comment so I can share this finding with my peers it will be greatly appreciated.


Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

When a thread is moved on the Ranch, it just goes from one forum to some other, more you just click on it in the original forum, and you're automatically taken to the new location in the new forum. It's in "Java in General" now, and this link should take you there:

I'll close this for you, as it's just a duplicate.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Final modifier applied to local variables - Java performance tuning
It's not a secret anymore!