The Artima Developer Community
Sponsored Link

Java Answers Forum
inner classes

3 replies on 1 page. Most recent reply: Mar 30, 2003 8:09 AM by Aladdin Mouhaimeed

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Aladdin Mouhaimeed

Posts: 11
Nickname: aladdin11
Registered: Mar, 2003

inner classes Posted: Mar 26, 2003 3:30 AM
Reply to this message Reply
Advertisement
A nested class declared within a method or other smaller block of code has access to any final, local variables in scope.
My question is: why should a local variable in a method be final to be accessed from an inner class in this method.
Can you just tell me what is the point of that?.


Vincent O'Sullivan

Posts: 724
Nickname: vincent
Registered: Nov, 2002

Re: inner classes Posted: Mar 26, 2003 8:52 AM
Reply to this message Reply
I think it is so that the link between the variable and the inner class can be made at compile time.

Vince.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: inner classes Posted: Mar 26, 2003 10:23 AM
Reply to this message Reply
It makes sense, since an instance of the inner class that is created could outlive the scope of the method that created it. In that case, the inner class object (that was probably returned or passed to another method) will have a reference that is in a scope that no longer exists.

Aladdin Mouhaimeed

Posts: 11
Nickname: aladdin11
Registered: Mar, 2003

Re: inner classes Posted: Mar 30, 2003 8:09 AM
Reply to this message Reply
Both of you gentlemen have made me a good favor, thank you very much indeed.

Flat View: This topic has 3 replies on 1 page
Topic: How to make javadoc comments in my sources quickly? Previous Topic   Next Topic Topic: how can i read individual String  from a String

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use