*
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
Author

Final modifier applied to local variables - Java performance tuning

Kevin Hermann
Greenhorn

Joined: Aug 12, 2010
Posts: 7
Hi,

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.

Cheers!


SCJP 6, SCWCD 5
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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:

http://www.coderanch.com/t/506424/java/java/Final-modifier-Java-performance-tuning

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


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Final modifier applied to local variables - Java performance tuning
 
Similar Threads
what is effect of object oriented on performance?
regarding static variables
What is Compile time constant?
method
Final modifier and Java performance tuning