aspose file tools*
The moose likes Java in General and the fly likes why netbeans suggested to make my local  reference variable final ? 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 netbeans suggested to make my local  reference variable final ?" Watch "why netbeans suggested to make my local  reference variable final ?" New topic
Author

why netbeans suggested to make my local reference variable final ?

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692


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 ?


The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14103
    
  16

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why netbeans suggested to make my local reference variable final ?