File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inner class within a static method

 
Justyna Wozniak
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 94
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic