aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Inner class within a static method 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 "Inner class within a static method" Watch "Inner class within a static method" New topic
Author

Inner class within a static method

Justyna Wozniak
Greenhorn

Joined: Oct 04, 2006
Posts: 14
Hello,
here's the code sample:

I do understand why an inner class within a static method has access to all static methods of the encapsulating class, but I don't understand why it also has access to all final authomatic variables within the encapsulating method (and no access to non-final authomatic variable in that method).
Does it also have any access to any other final variables in that class?

Thanks in advance,
Justyna W.
[ October 14, 2006: Message edited by: Barry Gaunt ]
James Quinton
Ranch Hand

Joined: Oct 02, 2006
Posts: 94
because our law said so.
refer to JLS 8.1.3
it clearly says:
method local variable not declared inside inner class must declared "final"
Santhosh Raje
Greenhorn

Joined: Sep 26, 2006
Posts: 9
Hey,
Since the final variable inside the method is a constant whose value is not going to be changed ,Hence even if there are multiple instances of Inner class objects the value of this variable is not going to be changed.
 
 
subject: Inner class within a static method