• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why access to non-final local variables is not permitted from local classes?

 
sura watthana
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm wondering why access to non-final local variables is not permitted from local classes? Could somebody tell me the reason why? Thank you

 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read this article
http://www.javaranch.com/campfire/StoryInner.jsp
 
Saheed Adepoju
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that local variables are only available to the method! After the method returns there would be no reference to the variable any longer! But if it were made final the value of the local variable doesnt change even if the method returns1 hope u understand.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic