File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Why to Mark as Final when accessed from Inner Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Why to Mark as Final when accessed from Inner Class" Watch "Why to Mark as Final when accessed from Inner Class" New topic
Author

Why to Mark as Final when accessed from Inner Class

Ragupathirajan Venkatesan
Ranch Hand

Joined: Aug 18, 2010
Posts: 62
Dear All,

I have method level local variable and i am using inside the inner class with in that method. System asking me to declare it has final variable. Please advise the reason behind that. example below.
public HashMap getValues(){
HashMap csvMap=null;
return (Forum) jdbcTemplate.queryForObject(query, new Object[] { Integer.valueOf(forumId) },
new RowMapper() {
public Object mapRow(ResultSet resultSet, int rowNum) throws SQLException {
while(resultSet.next){
csvMap.put(resultSet.getString(1),resultSet.getString(2));
}
}
});
}
csvMap is the local variable I am using.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

First of all, please apply code tag when you post code and people can read your post easily. so that you can get more response for your question.

Coming to your question, check out this thread
Ragupathirajan Venkatesan
Ranch Hand

Joined: Aug 18, 2010
Posts: 62
Hi Seetharaman,

Thanks for your reply and advice.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Ragupathirajan Venkatesan wrote:
Thanks for your reply


You are welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why to Mark as Final when accessed from Inner Class