• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why netbeans suggested to make my local reference variable final ?

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

when i was doing this code netbeans suggested me to make my reference variable edit as "final" i dont understand why , so ?
whats wrong if i dont make it final ?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have an anonymous inner class in lines 12 to 31. Local variables (including arguments) can only be accessed from an anonymous inner class if they are final. So, edit must be final, otherwise you can't use it in lines 17, 18 and 24, 25.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic