aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Annonymous Inner class doesnt use final var Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Annonymous Inner class doesnt use final var" Watch "Annonymous Inner class doesnt use final var" New topic
Author

Annonymous Inner class doesnt use final var

Paul Salerno
Ranch Hand

Joined: Jan 17, 2002
Posts: 172

I wanted to be sure that in this case it is not necessary for items to be declared final, since its being used w/in the annonymous inner class. Also wanted to be sure that if this were the case that this annonymous inner class were inside a method, then and only then, would the methods local var and parameter need to be final.
Thanks guys
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
Your example looks fine.
You only need to worry about final local variables in the method that contains an inner class, anonymous or not. And remember that method arguments are local variables as well. But any local variables you create *inside* your inner class are fine and don't need final.
Rob


Rob
SCJP 1.4
Paul Salerno
Ranch Hand

Joined: Jan 17, 2002
Posts: 172
Thanks G its all clear to me now, appreciate that. Issue closed
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
Oh, I dunno. It seems like issues never get closed around here
Rob :roll:
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Originally posted by Rob Ross:
Oh, I dunno. It seems like issues never get closed around here
Rob :roll:

What do you mean ?


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Annonymous Inner class doesnt use final var